Skip to content

Commit

Permalink
hotfix - web - platform.localeName
Browse files Browse the repository at this point in the history
  • Loading branch information
msayed-net committed Jan 1, 2025
1 parent dfac6b2 commit 69ee6bb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

* Add more features

## 6.0.8

* Hotfix for web

## 6.0.7

* init() : add `assetLoadersExtra` parameter to change the default assetLoadersExtra
Expand Down
7 changes: 7 additions & 0 deletions lib/src/core/localize_and_translate.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import 'dart:io';
import 'dart:ui' as ui;

import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:hive_flutter/hive_flutter.dart';
import 'package:localize_and_translate/src/assets/asset_loader_base.dart';
Expand Down Expand Up @@ -282,6 +284,11 @@ class LocalizeAndTranslate {
/// ### Returns device locale.
/// ---
static String _getDeviceLocale() {
if (kIsWeb) {
// Use `window.locale` for web
return ui.window.locale.toString();
}
// Fallback for non-web platforms
return Platform.localeName;
}

Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: localize_and_translate
description: Flutter localization in easy steps, simple ways to localize and translate your app
version: 6.0.7
version: 6.0.8
homepage: https://github.com/msayed-net/localize_and_translate
issue_tracker: https://github.com/msayed-net/localize_and_translate/issues

Expand Down

0 comments on commit 69ee6bb

Please sign in to comment.