在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):smartnsoft/FlappyTranslator开源软件地址(OpenSource Url):https://github.com/smartnsoft/FlappyTranslator开源编程语言(OpenSource Language):Dart 95.8%开源软件介绍(OpenSource Introduction):flappy_translatorA tool which automatically generates Flutter localization resources from CSV and Excel files. This is especially useful as any team member can edit the CSV/Excel file, with the subsequent translations imported into the project via a terminal command. Basic variables (strings and integers) are supported, however neither genders nor plurals are planned to be supported. If you require such functionality, consider using arb_generator. Note that as of version 2.0.0, null safe code is generated. Please use version 1.5.0 for non-null safe projects. Getting StartedIn order to use the flappy_translator package, please provide your translations in a CSV or Excel file. For CSV files, delimiters
Localizations can be specified for a region by appending the country code. Add dependencydependencies:
flutter_localizations:
sdk: flutter
dev_dependencies:
flappy_translator: Note that flappy_translator requires dart sdk >= 2.12. Define SettingsSettings for flappy_translator must set in your project's pubspec.yaml file. flappy_translator:
input_file_path: "test.csv"
output_dir: "lib"
file_name: "i18n"
class_name: "I18n"
delimiter: ","
start_index: 1
depend_on_context: true
use_single_quotes: false
replace_no_break_spaces: false
expose_get_string: false
expose_loca_strings: false
expose_locale_maps: false
generate_comments: false
comment_languages: []
Run packageMake sure that your current working directory is the project root. flutter pub get
flutter pub run flappy_translator Update iOS Info.plistFor iOS, ios/Runner/Info.plist needs to be updated with an array of the languages that the app will supports: <key>CFBundleLocalizations</key>
<array>
<string>fr</string>
<string>en</string>
<string>de</string>
</array> For more information, see Internationalizing Flutter apps. Use the i18n generated fileThe package used your input file in order to generate a file named file_name in output_dir you provided. The following example uses the default class_name I18n with a dependency on BuildContext. Firstly, add the I18nDelegate to your delegates: class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
localizationsDelegates: [
const I18nDelegate(),
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: I18nDelegate.supportedLocals,
home: Home(),
);
}
} Then use the generated I18n class! class Home extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('flappy_translator'),
),
body: Center(
child: Column(
children: <Widget>[
Text(I18n.of(context).plainText),
Text(I18n.of(context).welcome(name: 'Dash')),
Text(I18n.of(context).favoriteColor),
],
),
),
);
} Please see example for more information. Material LocalizationsSupporting a language (i.e. ga or cy) not included in GlobalMaterialLocalizations requires adding a material localization class and delegate. Although this is out of the scope of this package, a warning is logged to the console during code generation. More info. Rules and functionalitiesLocaleLocales are specified in the top row and are expected to be given in the form Default languageThe column at
KeysEach loca key must begin with a lowercase letter, after which any combinations of lowercase, uppercase, digits or underscores are valid. VariablesIn order to include variables in loca strings, they need to be written in the format
All variables are required. Consider the key String welcome({
required String name,
}) Note that if the variable's name starts with a number, the generated variable name will be |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论