slang-i18n / slang Goto Github PK
View Code? Open in Web Editor NEWType-safe i18n for Dart and Flutter
Home Page: https://pub.dev/packages/slang
License: MIT License
Type-safe i18n for Dart and Flutter
Home Page: https://pub.dev/packages/slang
License: MIT License
Without build.yaml config command flutter pub run fast_i18n
generate this class:
But when I add build.yaml with:
targets:
$default:
builders:
fast_i18n:
options:
base_locale: cs
translate_var: translate
key_case: camel
string_interpolation: double_braces
Where name is undefined variable because $
symbol is not escaped by \$
.
My strings.i18n.json is:
{
"title": "Scanner pro vážení balíků",
"scanner_informations": "Scanner informations",
"scale_informations": "Scale informations",
"hello": "Hello $name",
"save": "Save",
"login": {
"fail": "Logged in failed"
}
}
With the latest build runner, next error occurs during code generation:
../../../../.pub-cache/hosted/pub.dartlang.org/analyzer-1.5.0/lib/src/error/best_practices_verifier.dart:266:50: Error: The property 'displayString' is defined in multiple extensions for 'TargetKind' and neither is more specific.
- 'TargetKind' is from 'package:meta/meta_meta.dart' ('../../../../.pub-cache/hosted/pub.dartlang.org/meta-1.7.0/lib/meta_meta.dart').
Try using an explicit extension application of the wanted extension or hiding unwanted extensions from scope.
var kindNames = kinds.map((kind) => kind.displayString).toList()
^^^^^^^^^^^^^
../../../../.pub-cache/hosted/pub.dartlang.org/analyzer-1.5.0/lib/src/error/best_practices_verifier.dart:1978:14: Context: This is one of the extension members.
String get displayString {
^^^^^^^^^^^^^
../../../../.pub-cache/hosted/pub.dartlang.org/meta-1.7.0/lib/meta_meta.dart:91:14: Context: This is one of the extension members.
String get displayString {
^^^^^^^^^^^^^
../../../../.pub-cache/hosted/pub.dartlang.org/analyzer-1.5.0/lib/src/error/best_practices_verifier.dart:268:36: Error: The getter 'commaSeparatedWithOr' isn't defined for the class 'List<dynamic>'.
- 'List' is from 'dart:core'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'commaSeparatedWithOr'.
var validKinds = kindNames.commaSeparatedWithOr;
^^^^^^^^^^^^^^^^^^^^
../../../../.pub-cache/hosted/pub.dartlang.org/analyzer-1.5.0/lib/src/error/best_practices_verifier.dart:1978:14: Error: A non-null value must be returned since the return type 'String' doesn't allow null.
String get displayString {
^
```
To set a default language, a configuration was made in build.yaml
file, where base_locale
was set to hr
targets:
$default:
builders:
fast_i18n:
options:
base_locale: hr #<<<<<
fallback_strategy: base_locale
input_directory: lib/core/i18n
input_file_pattern: .i18n.json
output_directory: lib/core/i18n
output_file_pattern: .g.dart
translate_var: tr
enum_name: AppLocale
translation_class_visibility: private
Configuration along with generated dart code is as following:
The issue is at the startup when translation is fetched from json file, it does not get translation from default language/base_locale as it should, but rather it displays English translation (Loyalty club):
Text(tr.landing.benefitsClub), // displays "Loyalty club"
Motivation
Making migrations easier
Developer Experience
Add new command flutter pub run fast_i18n migrate-arb source.arb destination.i18n.json
Are there plans to support plural forms?
Motivation
To reduce asset size, developers can extract the translations to the server.
The translations will be fetched at runtime.
Developer Experience
Because every key needs to be known at compile time, the base translations must be available.
// strings.i18n.json
{
"greet": "Welcome {name}"
}
Now load a locale:
// your logic, represents ONE locale!
Map fetchFromServer() {
return {
'greet': 'Hello {name}'
}
}
// via LocaleSettings
void example1() {
String a = t.greet(name: 'Tom'); // "Welcome Tom"
Map data = fetchFromServer();
LocaleSettings.loadCustom(data); // the new load function
String b = t.greet(name: 'Tom'); // "Hello Tom"
}
// via dependency injection
void example2() {
String a = t.greet(name: 'Tom'); // "Welcome Tom"
Map data = fetchFromServer();
final t2 = AppLocaleUtils.buildCustom(data); // the new build function
String b = t2.greet(name: 'Tom'); // "Hello Tom"
}
This will blow up the generated file. Therefore, this should be opt-in.
targets:
$default:
builders:
fast_i18n:
options:
contexts:
dynamic_translations: true # enable this feature
After migrating to 5.0.0 the generated d.dart
file is not compiling in my project. It is throwing a type errors
lib/l10n/messages.g.dart:136:59: Error: 'PluralResolver' isn't a type.
static void setPluralResolver({required String language, PluralResolver? cardinalResolver, PluralResolver? ordinalResolver}) {
^^^^^^^^^^^^^^
lib/l10n/messages.g.dart:136:93: Error: 'PluralResolver' isn't a type.
static void setPluralResolver({required String language, PluralResolver? cardinalResolver, PluralResolver? ordinalResolver}) {
^^^^^^^^^^^^^^
lib/l10n/messages.g.dart:137:33: Error: Getter not found: '_pluralResolversCardinal'.
if (cardinalResolver != null) _pluralResolversCardinal[language] = cardinalResolver;
^^^^^^^^^^^^^^^^^^^^^^^^
lib/l10n/messages.g.dart:138:32: Error: Getter not found: '_pluralResolversOrdinal'.
if (ordinalResolver != null) _pluralResolversOrdinal[language] = ordinalResolver;
Here's my configuration in build.yaml
targets:
$default:
builders:
fast_i18n:
options:
input_directory: res/l10n
output_directory: lib/l10n
translation_class_visibility: public
Is it possible to change (or customize) the "t" access variable? e.g. t.my.string.path
becomes i18n.my.string.path
?
Motivation
Sometimes, the translations will be fetched from the server. For example, a news page where the strings are not known during compile-time.
Developer Experience
For overwritable nodes: Create a new function void overwriteTranslations({ <attributes> })
which sets the new translations.
String before = t.pages.newsPage.title;
// current locale
t.pages.newsPage.overwriteTranslations(
title: 'New Title',
content: fetchedContent,
);
String after = t.pages.newsPage.title; // 'New Title'
// custom locale
AppLocale.fr.translations.pages.newsPage.overwriteTranslations(
title: fetchedTitle,
content: fetchedContent,
);
The selected nodes are specified in build.yaml
similar to maps:
targets:
$default:
builders:
fast_i18n:
options:
overwritable:
- pages.newsPage
When I try to generate the strings.g.dart file using the build_runner, I get the following error:
[SEVERE] fast_i18n:i18nBuilder on lib/presentation/core/i18n/strings.i18n.json:
This builder requires Dart inputs without syntax errors.
However, package:brickfact/presentation/core/i18n/strings.i18n.json (or an existing part) contains the following errors.
strings.i18n.json:1:1: Expected a method, getter, setter or operator declaration.
When I try with the flutter pub run fast_i18n
command it works without issues. It would however be nice if it works with the build_runner, even if it is slower, as this command is always running. Is there a way to make this work?
Motivation
I use several packages that depend on code generation. So I have to run the code generation quite often. And each time the timestamp in the strings.g.dart
updates. I then have to revert that file, because at first glance in the git log it looks like the localization has changed, even though nothing has changed.
So it would be a nice QOL improvement :)
When using auto plural detection, then pluralization resolvers are not rendered.
Configuration:
fast_i18n:i18nBuilder:
enabled: true
options:
pluralization:
auto: cardinal
Reason:
So we can comment.
With current json implementation, it's impossible to comment.
We need to comment so the person who actually translate the text can have context.
Hi, thanks for your package, it's awesome!)
But it would be great if we will have possibility to set in and out file directories and in files regex.
For example in my case I store my locale files in assets/locale and them have names {languageName}.json
I think it's not logical to mix them with code files in lib directory because it's assets.
So it would be nice if I could set in dir => assets/locale, out dir => lib/i18n and files pattern => **.json
Btw also I think dependency of devicelocale
is reduntant because it haven't implementation for flutter desktop, but can be checked easy just like that
final locale = WidgetsBinding.instance.window.locale;
My project has over 7k source keys and over 14 languages. This makes the generated file over 2.5 MB in size, thus the IDE has problems caching/indexing the file. Maybe it is better to split the classes into separate files?
This release mostly focuses on simplifications of build.yaml
.
Simplify fast_i18n:i18nBuilder
to fast_i18n
.
targets:
$default:
builders:
fast_i18n: # no more "fast_i18n:i18nBuilder"
options:
base_locale: fr
Setting auto: cardinal
by default applies to most projects. This means that you don't need the pluralization
section at all in your build.yaml
!
targets:
$default:
builders:
fast_i18n:
options:
pluralization:
auto: cardinal # default
The previous default mode strict
has been renamed to none
, This makes more sense because there is no fallback strategy at all.
targets:
$default:
builders:
fast_i18n:
options:
fallback_strategy: none # was "strict"
Only for developers using both key_case
and any path related feature (maps
, pluralization
paths, context
paths).
Paths must be cased according to key_case
if specified.
{
"a_b": {
"hi": "hi"
}
}
targets:
$default:
builders:
fast_i18n:
options:
key_case: camel # this forces every other path also be in camel case
maps:
- aB
Null safety is must have. This will simplify the code base.
Let's say I want next string "{number}mm"
With that library it's only possible to do next:
"$number mm"
But I really don't want to use space here
How to handle such a case without splitting it into two strings
During generation output_directory
is ignored and input_directory
is used instead.
fast_i18n: 5.12.0
in build.yaml I turned off pluralization but in the generated file I have unused private methods _pluralCardinalEn and _pluralOrdinalEn.
Is it possible not to generate the mentioned methods?
Hi thanks for the code generator! However, I need it in pure Dart packages (as well as Flutter packages), but the generator generates code with import 'package:flutter/widgets.dart';
, which is impossible for dart packages.
Talking about #63, maybe we can create two supportive packages (instead of one), one for dart, one for flutter-specific features.
When compiling I get the following error:
/D:/flutter/.pub-cache/hosted/pub.dartlang.org/fast_i18n-3.0.3/lib/fast_i18n.dart:13:46: Error: Method 'toLanguageTag' cannot be called on 'Locale?' because it is potentially null.
- 'Locale' is from 'dart:ui'.
Try calling using ?. instead.
WidgetsBinding.instance?.window.locale.toLanguageTag();
The issue is resolved modifying:
class FastI18n {
static const _localePartsDelimiter = '-';
/// Returns the locale string used by the device.
static String? getDeviceLocale() =>
- WidgetsBinding.instance?.window.locale.toLanguageTag();
+ WidgetsBinding.instance?.window.locale?.toLanguageTag();
/// Returns the candidate (or part of it) if it is supported.
/// Fallbacks to base locale.
/// Please note that locales are case sensitive.
static String selectLocale(
String candidate, List<String> supported, String baseLocale) {
// normalize
candidate = Utils.normalize(candidate);
My config is:
$ cat pubspec.yaml
environment:
sdk: '>=2.12.0 <3.0.0'
$ flutter doctor
[√] Flutter (Channel stable, 2.0.4, on Microsoft Windows [Version 10.0.19042.867], locale en-BE)
Is it possible to verify this issue?
Hi @Tienisto,
Thanks for making this amazing library, I want to update the language for the whole app from the settings page.
I used LocaleSettings.setLocale('es'); in main page and it's working fine.
But I'm using MVVM architecture and I want to change the language from my view-model any suggestions from your side.
Is it possible to support csv files also? I think it is the easiest way to create and update translations.
Thank you for this helpful package.
I've noticed that if I use {snake_case}
in my translation strings, that the corresponding method does not apply camel case to the method's named parameters. For example, given the following translation string:
{
"visit_status": "{status_text} at {when}"
}
I would expect the following method signature to be generated with the named parameter statusText
having camel case applied.
String visitStatus({required Object statusText, required Object when}) => '$statusText at $when';
However, the following method signature is generated where the snake case has not been converted to camel case.
String visitStatus({required Object status_text, required Object when}) => '$status_text at $when';
My build.yaml
file is:
targets:
$defaults:
builders:
fast_i18n:
options:
fallback_strategy: base_locale
input_directory: lib/localizations
output_directory: lib/localizations
key_case: camel
string_interpolation: braces
Hi! I am using this package for my app but I also have older package with localization using intl
- like MyPackageLocalizations.of(context).blah
.
I have noticed that when I use LocaleSettings.setLocale()
, it doesn't set context's locale and so strings provided by that package are not translated.
Confirmed when I set MaterialApp(locale: myLocale)
, it works.
Do I need to set context's locale by myself?
Tried the steps in the description. I have 2 json files, fast-i18n dependencies are added,flutter packages pub run build_runner build
produces no output (except those ones by Hive which also uses build_runner).
Contents of strings.i18n.json
{
"entries": "esntries",
"search": "Search",
"type-in": "Type-in text below"
}
Part of the pubspec.yaml:
version: 1.0.0+1
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
provider: ^4.0.2
shared_preferences:
flutter_html: ^1.0.0
hive: ^1.4.1+1
hive_flutter: ^0.3.0+2
sprintf: "^4.0.0"
archive: ^2.0.13
flutter_sticky_header: ^0.4.2
reorderables: ^0.3.2
double_back_to_close_app: ^1.2.0
fluttertoast: ^7.0.1
file_picker: ^1.13.0+1
fast_i18n: ^1.4.0
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.3
dependency_overrides:
flutter_svg: 0.18.0 #Flutter 1.20 and flutter_html issue
path: 1.6.4
hive: # custom version remove box key assertion to be ASCII string not greater than 255 chars
path: ./plugins/hive-1.4.1+1/
reorderables:
path: ./plugins/reorderables-0.3.2/
dev_dependencies:
flutter_test:
sdk: flutter
hive_generator: ^0.7.0+2
build_runner: ^1.10.0
flutter_launcher_icons: ^0.7.3
flutter_native_splash: ^0.1.9
And that's flutter packages pub run build_runner build
output:
[INFO] Generating build script...
[INFO] Generating build script completed, took 549ms
[WARNING] Deleted previous snapshot due to missing asset graph.
[INFO] Creating build script snapshot......
[INFO] Creating build script snapshot... completed, took 15.0s
[INFO] Initializing inputs
[INFO] Building new asset graph...
[INFO] Building new asset graph completed, took 902ms
[INFO] Checking for unexpected pre-existing outputs....
[INFO] Found 1 declared outputs which already exist on disk. This is likely because the`.dart_tool/build` folder was deleted, or you are submitting generated files to your source repository.
[SEVERE] Conflicting outputs were detected and the build is unable to prompt for permission to remove them. These outputs must be removed manually or the build can be run with `--delete-conflicting-outputs`. The outputs are: lib/models/indexedDictionary.g.dart
Is it possible to have pluralization with multiple fields through linked translations? For example, if we have a strings.i18n.yaml
like:
login:
passwordInvalidFields:
characters:
one: $count character
other: $count characters
symbols:
one: $count symbol
other: $count symbols
passwordInvalid: Password must be at least @:login.passwordInvalidFields.characters long with at least @:login.passwordInvalidFields.symbols
It will generate code for this, but then there is only one named count parameter: t.login.passwordInvalid(count: _passwordMinLength)
so we can't specify the separate numbers for the number of characters and symbols. If instead the YAML is changed to:
login:
passwordInvalidFields:
characters:
one: $numCharacters character
other: $numCharacters characters
symbols:
one: $numSymbols symbol
other: $numSymbols symbols
passwordInvalid: Password must be at least @:login.passwordInvalidFields.characters long with at least @:login.passwordInvalidFields.symbols
then t.login.passwordInvalid
will have the numCharacters
and numSymbols
parameters but then also have a count
named parameter as well. Is it possible to use a named parameter other than $count
for pluralization? What is the right way to do pluralization of multiple items within a single sentence?
Of course, readme is good.
But a real project with example must be a plus I think
For example, if someone has issues with lib he always can run that example and play with it
Sometimes it's really difficult to understand why it not generated.
As for me it was .i18n suffix, and I think I'm not the only one who has such issues
Hello, I experiment with namespaces for split my one input file into more files.
I had in strings.i18n.json
this json structure:
{
"core": {
...
},
"app": {
"title": "Example App",
...
},
"auth": {
...
},
"barcode_registration": {
...
}
}
And I split it into this folder structure:
But when I run flutter pub run fast_i18n
command so it generate translations only for core, app and auth but
translations in barcode_registration section is not generated..:
Probably there is a problem with _
and it doesn't create barcodeRegistration
property.
Can you fix it please?
Here is my build.yaml
configuration:
targets:
$default:
builders:
fast_i18n:
options:
base_locale: cs
translate_var: translate
key_case: camel
key_map_case: camel
param_case: camel
string_interpolation: double_braces
input_directory: lib/core/i18n
namespaces: true
output_format: multiple_files
output_file_name: strings.g.dart
output_directory: lib/core/i18n
maps:
- core.changeLanguage.languages
Thank you very much.
I think it would be good feature to have the possibility to not apply key_case to maps. Or select different casing for maps. Or select different casing for each map (but I would be happy with global maps setting).
I am using key_case: camel
for all of my translations, because it's the Dart's language style.
My API returns JSON error response in format
{
"code": "user_not_found",
"reason": "User was not found."
}
and now I would like to use that code to lookup the translated reason message.
Something like
try {
something();
} on ApiException catch (ex) {
_notificationService.showError(t.apiCodes[ex.code]);
}
but since all keys are now camelCase
, I would need to do my own recasing of API response codes to camelCase
. Which is not a big deal but this feature would still be great :)
Hi,
I wonder if there is better way to add keys and rebuild project. My current setup with 6 languages is such:
This is just too time consuming, because first, I cannot use string unless it's in all translation files, otherwise the project will not build. Second, running flutter run pub fast_i18n is again manual step - can this be automated with auto-reload?
Describe the bug
Using flutter pub build_runner build
outputs nothing. If I make a change to my json file with my strings and check the generated file it has not been written to, nor does it contain a field for the new string/text. The output from build runner seems to confirm this.
$ flutter pub run build_runner build --delete-conflicting-outputs
[INFO] Generating build script...
[INFO] Generating build script completed, took 542ms
[INFO] Initializing inputs
[INFO] Reading cached asset graph...
[INFO] Reading cached asset graph completed, took 70ms
[INFO] Checking for updates since last build...
[INFO] Checking for updates since last build completed, took 373ms
[INFO] Running build...
[INFO] Running build completed, took 8ms
[INFO] Caching finalized dependency graph...
[INFO] Caching finalized dependency graph completed, took 37ms
[INFO] Succeeded after 60ms with 0 outputs (0 actions)
If I run fast_i18n "directly" with flutter pub run fast_i18n
it works with the generated files updated with my new string keys.
My build.yaml
looks like:
# yaml-language-server: $schema=https://json-schema.org/draft-07/schema#
targets:
$default:
builders:
fast_i18n:
options:
base_locale: en
namespaces: true
fallback_strategy: base_locale
input_directory: strings
input_file_pattern: .i18n.json
output_directory: lib/i18n
output_format: multiple_files
Versions from my pubspec
build_runner: ^2.1.7
fast_i18n: ^5.11.0
To Reproduce
Steps to reproduce the behavior:
flutter pub run fast_i18n
and observe that files are generated correctly.flutter pub run build_runner build --delete-conflicting-outputs
.Expected behavior
Generate files both using the build runner and the fast_i18n task
Affected version: 5.6.0
Setting following in build.yaml does not seem to have effect on generated maps case:
key_map_case: pascal
flat_map: false
maps:
- ProjectActivityType
- AddressBookType
key_map_case
case transformation is ignored.JSON:
{
"AddressBookType": {
"COMPANY": "Company",
"PERSON": "Person"
}
}
will produce nin strings.g.dart:
AppLocale.cs: {
'addressBookType.company': 'Firma',
'addressBookType.person': 'Osoba',
}
Hello @Tienisto
For the translators it would be helpful to have some information like source keys count and word count.
Can you output this information to the console after the build process?
Thank you for the best localization plugin ✨
Hello,
my translation files are getting big very fast. I really like to have a json file for components, for services etc. split up and not in one file per language. I dont want to write my own service which merges multiple files into one to compile it with the runner afterwards.
Are you planning on introducing multiple file support per language?
Best regards
The app crashes with following error. I used string.cs_CZ.i18n.json
file and also LocaleSettings.setLocaleRaw("cs_CZ");
I/flutter ( 5843): ════════
I/flutter ( 5843): Warning: This application's locale, cs_CZ, is not supported by all of its
I/flutter ( 5843): localization delegates.
I/flutter ( 5843): > A MaterialLocalizations delegate that supports the cs_CZ locale was not found.
I/flutter ( 5843): See https://flutter.dev/tutorials/internationalization/ for more
I/flutter ( 5843): information about configuring an app's locale, supportedLocales,
I/flutter ( 5843): and localizationsDelegates parameters.
I/flutter ( 5843): ════════
I/flutter ( 5843):
======== Exception caught by widgets library =======================================================
The following assertion was thrown building AppBar(dirty, dependencies: [_LocalizationsScope-[GlobalKey#0dcea]], state: _AppBarState#471e0):
No MaterialLocalizations found.
AppBar widgets require MaterialLocalizations to be provided by a Localizations widget ancestor.
The material library uses Localizations to generate messages, labels, and abbreviations.
To introduce a MaterialLocalizations, either use a MaterialApp at the root of your application to include them automatically, or add a Localization widget with a MaterialLocalizations delegate.
The specific widget that could not find a MaterialLocalizations ancestor was: AppBar
dirty
dependencies: [_LocalizationsScope-[GlobalKey#0dcea]]
state: _AppBarState#471e0
The ancestors of this widget were:
: Scaffold
dependencies: [_InheritedTheme, MediaQuery, _EffectiveTickerMode, _LocalizationsScope-[GlobalKey#0dcea], Directionality, UnmanagedRestorationScope, _ScaffoldMessengerScope]
state: ScaffoldState#1a26c(tickers: tracking 2 tickers)
: MyHomePage
dependencies: [MediaQuery]
state: _MyHomePageState#24804
: MaterialApp
state: _MaterialAppState#c0250
: MyApp
: _InheritedLocaleData
: TranslationProvider-[LabeledGlobalKey<_TranslationProviderState>#7e437]
state: _TranslationProviderState#794d5
...
The relevant error-causing widget was:
Describe the bug
Empty lists throw an error
To Reproduce
Generate the i18n file using this json:
{
"title": "hi",
"features": []
}
And add an interface:
targets:
$default:
builders:
fast_i18n:
options:
interfaces:
Test: test
Expected behavior
Should render a getter returning an empty list. E.g. List<String> features => [];
Note: key_case is snake.
Example is key in json "toast_cycle_alert_30_min" and get method is named as "toast_cycle_alert_3_0_min"
Motivation
If a different output directory than the input directory is defined, and any of these directories does not exist an error will be thrown.
Generating translations...
Found build.yaml in /Users/.../code/app/build.yaml
-> fileType: json
-> baseLocale: en
-> fallbackStrategy: baseLocale
-> inputDirectory: /Users/.../code/app/strings
-> inputFilePattern: .i18n.json
-> outputDirectory: /Users/.../code/app/lib/i18n
-> outputFilePattern (deprecated): .g.dart
-> outputFileName: null
-> outputFileFormat: multipleFiles
-> renderLocaleHandling: true
-> namespaces: false
-> translateVar: t
-> enumName: AppLocale
-> translationClassVisibility: private
-> keyCase: null (no change)
-> keyCase (for maps): null (no change)
-> paramCase: null (no change)
-> stringInterpolation: dart
-> renderFlatMap: true
-> renderTimestamp: true
-> maps: []
-> pluralization/auto: cardinal
-> pluralization/cardinal: []
-> pluralization/ordinal: []
-> contexts: no custom contexts
-> interfaces: no interfaces
Found base name: "strings" (used for output file name and class names)
Scanning translations...
(base) en -> /Users/.../code/app/strings/strings.i18n.json
Unhandled exception:
FileSystemException: Cannot open file, path = '/Users/.../code/app/lib/i18n/strings.g.dart' (OS Error: No such file or directory, errno = 2)
#0 _File.throwIfError (dart:io/file_impl.dart:635:7)
#1 _File.openSync (dart:io/file_impl.dart:479:5)
#2 _File.writeAsBytesSync (dart:io/file_impl.dart:604:31)
#3 _File.writeAsStringSync (dart:io/file_impl.dart:628:5)
#4 generateTranslations (file:///Users/.../flutter/.pub-cache/hosted/pub.dartlang.org/fast_i18n-5.10.0/bin/fast_i18n.dart:341:10)
<asynchronous suspension>
#5 main (file:///Users/.../flutter/.pub-cache/hosted/pub.dartlang.org/fast_i18n-5.10.0/bin/fast_i18n.dart:47:5)
<asynchronous suspension>
pub finished with exit code 255
There should either be a more descriptive error, or the ability to create the intermediate output directories (in this case the i18n
directory inside lib
).
Developer Experience
A field in build.yaml can control if directories should be turned on
This is an idea for the next feature introducing custom contexts.
Motivation
There should be an option to differentiate between male and female forms. It should be generic so we can add more use cases.
Developer Experience
Similar to pluralization, there should be an additional parameter. Here it will be context
.
{
"welcome": {
"male": "Mr $name",
"female": "Ms $name"
}
}
String a = t.welcome(name: 'Tom', context: GenderContext.male);
The enum should be configurable. There can be more than one context type.
targets:
$default:
builders:
fast_i18n:i18nBuilder:
options:
contexts:
gender_context: # The resulting enum will be in pascal case, i.e. "GenderContext"
enum:
- male
- female
auto: false
paths:
- welcome
polite_context: # Imaginary context type called "PoliteContext"
enum:
- polite
- neutral
- rude
auto: on
Some languages may have fewer context types, therefore we may collapse them:
{
"welcome": {
"male,female": "$name"
}
}
Currently, only linked translations are supported which do not accept any parameters.
This is how it should look like, when parameters are supported:
{
"myName": "my name is $name",
"myAge": "I am $age years old",
"introduce": "Hello, @:myName and @:myAge"
}
Combine the parameters.
String s = t.introduce(name: 'Tom', age: 27); // Hello, my name is Tom and I am 27 years old.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.