Closed niccokunzmann closed 7 months ago
I would also like to add that this code just lists all the JSON files and adds the language codes automatically:
import 'package:path/path.dart' as path;
var delegate = await LocalizationDelegate.create(
fallbackLocale: 'en_US',
supportedLocales: Directory('assets/i18n')
.listSync(recursive: false)
.map((e) => path.basenameWithoutExtension(e.toString()))
.toList());
I wonder: That could be a nice fast default.
Hi @niccokunzmann, thanks for your contribution!
I have fixed the assets path. Other than that:
The following is not required:
flutter_localizations:
sdk: flutter
Neither is the flutter_localizations import.
import 'package:flutter_localizations/flutter_localizations.dart';
JSON files can have different formats (inline, nested, etc.) so I will not add here the example for creating localization files. Example app contains various files which showcase this.
And create the first localization file assets/i18n/en.json
The MaterialApp title is usually the app's name and you don't want to translate that.
title: translate('app.title'),
There is an example below on how to use the translation feature
translate('your.localization.key');
Hi, thanks for changing some of it.
These lines require the import:
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
import 'package:flutter_localizations/flutter_localizations.dart';
As the creator, please do not tell me why I do not need certain documentation. If you want me and others to add, please let me add imperfect stuff and it will get better over time.
you don't want to translate that
Yes, I want that. The name does not make sense in Russian and Chinese. You make assumptions.
translate('your.localization.key');
This should correspond to the JSON. For someone using this module the first time, it can take a while to understand how to structure the JSON file. Nice would be if a reference to a standard like this one: https://help.transifex.com/en/articles/6220806-json-with-icu-plurals
Examples are not documentation. They are in between documentation and code.
Would you like to re-open the issue? If my improvements are a bit too much, I can hear that!
As the creator, please do not tell me why I do not need certain documentation. If you want me and others to add, please let me add imperfect stuff and it will get better over time.
You suggested some changes and I decided not to publish them, and provided you with feedback.
Yes, I want that. The name does not make sense in Russian and Chinese.
You make assumptions.
In most cases, the app name remains untranslated. It's a design choice. You're free to localize it in your projects.
Suggestions are welcome, but as the maintainer, I decide on their implementation.
Hi,
I will make some changes to the Wiki because I am a beginner and the documentation needs a few changes to make it work for me.
You can pull them here: https://github.com/niccokunzmann/flutter_translate-wiki/tree/master