Jonatas

Improve translations docs

## [3.7.0]
- Added: RxSet. Sets can now also be reactive.
- Added isDesktop/isMobile (@roipeker)
- Improve GetPlatform: It is now possible to know which device the user is using if GetPlatform.isWeb is true.
context.responsiveValue used device orientation based on web and non-web applications. Now it checks if it is a desktop application (web or desktop application) to do the responsiveness calculation.
context.responsiveValue used device orientation based on web and non-web applications. Now it checks if it is a desktop application (web or desktop application) to do the responsiveness calculation. (@roipeker)
- Change: The documentation previously stated that Iterables should not access the ".value" property.
However, many users did not pay attention to this fact, and ended up generating unnecessary issues and bugs in their application.
In this version, we focus on code security. Now ".value" is protected, so it cannot be accessed externally by Lists, Maps or Sets.
... ...
... ... @@ -329,29 +329,29 @@ Pass parameters to `GetMaterialApp` to define the locale and translations.
```dart
return GetMaterialApp(
translations: Messages(), // your translations
locale: Locale('en_US'), // translations will be displayed in that locale
fallbackLocale: Locale('en_US'), // specify the fallback locale in case an invalid locale is selected.
supportedLocales: <Locale>[Locale('en_US'), Locale('de_DE')] // specify the supported locales
locale: Locale('en', 'US'), // translations will be displayed in that locale
fallbackLocale: Locale('en', 'UK'), // specify the fallback locale in case an invalid locale is selected.
supportedLocales: <Locale>[Locale('en', 'UK'), Locale('en', 'US'), Locale('de','DE')] // specify the supported locales
);
```
#### Change locale
Call `Get.updateLocale(locale)` to update the locale. Translations then automatically use the new locale.
```dart
var locale = Locale('en_US');
var locale = Locale('en', 'US');
Get.updateLocale(locale);
```
#### System locale
To read the system locale, you could use `Platform.localeName`.
To read the system locale, you could use `window.locale`.
```dart
import 'dart:ui' as ui;
return GetMaterialApp(
locale: Locale(Platform.localeName),
locale: ui.window.locale,
);
```
### More details about internationalization
**See a more in-depth explanation of internationalization [here](./docs/en_US/internationalization.md)**
## Change Theme
Please do not use any higher level widget than GetMaterialApp in order to update it. This can trigger duplicate keys. A lot of people are used to the prehistoric approach of creating a "ThemeProvider" widget just to change the theme of your app, and this is definitely NOT necessary with Get.
... ...
## Translations
Translations are kept as a simple key-value dictionary map.
To add custom translations, create a class and extend `Translations`.
```dart
import 'package:get/get.dart';
class Messages extends Translations {
@override
Map<String, Map<String, String>> get keys => {
'en_US': {
'hello': 'Hello World',
},
'de_DE': {
'hello': 'Hallo Welt',
}
};
}
```
### Using translations
Just append `.tr` to the specified key and it will be translated, using the current value of `Get.locale` and `Get.fallbackLocale`.
```dart
Text('title'.tr);
```
## Locales
Pass parameters to `GetMaterialApp` to define the locale and translations.
```dart
return GetMaterialApp(
translations: Messages(), // your translations
locale: Locale('en_US'), // translations will be displayed in that locale
fallbackLocale: Locale('en_US'), // specify the fallback locale in case an invalid locale is selected.
supportedLocales: <Locale>[Locale('en_US'), Locale('de_DE')] // specify the supported locales
);
```
### Change locale
Call `Get.updateLocale(locale)` to update the locale. Translations then automatically use the new locale.
```dart
var locale = Locale('en_US');
Get.updateLocale(locale);
```
### System locale
To read the system locale, you could use `Platform.localeName`.
```dart
return GetMaterialApp(
locale: Locale(Platform.localeName),
);
```