सार्वजनिक जानकारी से बना चयन मार्गदर्शन। केवल संदर्भ हेतु।
LocalizationBuilder एक Flutter पैकेज है जिसका उद्देश्य स्थानीयकरण डेटा क्लासेस के निर्माण और प्रबंधन को सुगम बनाना है। यह स्थानीयकरण स्रोतों—जैसे एक्सेल फ़ाइल या JSON फ़ाइल—से प्रकार-सुरक्षित, संरचित कोड का उत्पादन करता है, जिससे बॉयलरप्लेट कोड कम होता है और अंतरराष्ट्रीय ऐप में त्रुटियाँ कम होती हैं। बिल्डर भाषाओं के बीच सुसंगतता सुनिश्चित करता है और स्वचालित रूप से स्थानीयकरण कुंजियों और उनके संबंधित मानों के उत्पादन के माध्यम से अनुवाद कार्य प्रक्रिया को सरल बनाता है। बहुभाषी ऐप में रखरखाव और स्केलेबिलिटी को बढ़ावा देने के लिए टीमों के लिए आदर्श है।
उपयोग
स्प्रेडशीट से स्थानीयकरण कुंजियाँ उत्पन्न करना
अनुवाद फ़ाइल सृजन को स्वचालित करना
स्थिर की नामकरण बनाए रखना
टीम-आधारित अनुवाद कार्यप्रवाहों का समर्थन करना
बहुभाषी एप्लिकेशन विकास को सरल बनाना
मुख्य विशेषताएँ
प्रकार सुरक्षित स्थानीयकरण क्लासेज़ स्वचालित रूप से उत्पन्न करता है
स्प्रेडशीट-आधारित अनुवाद स्रोत के साथ एकीकृत होता है
हाथ से कुंजी प्रबंधन को कम करता है
सुनिश्चित करें कि की संरचना समान रहे
कई आउटपुट प्रारूपों का समर्थन करता है
इनके लिए उपयुक्त
बहुभाषी ऐप बना रहे विकासकर्मी
बाहरी अनुवाद सहायता का उपयोग करने वाली टीमें
स्केलेबल स्थानीयकरण की आवश्यकता वाले प्रोजेक्ट
अक्सर भाषा अपडेट करने वाले ऐप्स
कोड गुणवत्ता और सामंजस्य को प्राथमिकता देने वाली टीमें
विचार योग्य बातें
स्रोत डेटा प्रारूप की स्थापना की आवश्यकता है
अनुवाद के लिए बाहरी उपकरण पर निर्भर है
जटिल संरचनाओं के लिए कस्टम कॉन्फ़िगरेशन की आवश्यकता हो सकती है
केंद्रीकृत अनुवाद प्रबंधन वाले प्रोजेक्ट्स के लिए सर्वोत्तम
सरल एक भाषा ऐप्स के लिए आदर्श नहीं है
मूल README
संबंधित सोर्स रिपॉज़िटरी के मूल README का स्नैपशॉट। नवीनतम सामग्री के लिए रिपॉज़िटरी देखें।
Flutter Google Sheet localizations generator
Generates a localizations delegate from an online Google Sheet file.
Extract from the link the DOCID and SHEETID values : https://docs.google.com/spreadsheets/d/<DOCID>/edit#gid=<SHEETID>) :
2. Declare a localization delegate
Declare the following AppLocalizationsDelegate class with the SheetLocalization annotation pointing to your sheet in a lib/localization.dart file :
import'package:flutter/widgets.dart';
import'package:flutter/foundation.dart';
import'package:flutter_sheet_localization/flutter_sheet_localization.dart';
part'localization.g.dart';
@SheetLocalization("DOCID", "SHEETID", 1) // <- See 1. to get DOCID and SHEETID// the `1` is the generated version. You must increment it each time you want to regenerate// a new version of the labels.classAppLocalizationsDelegateextendsLocalizationsDelegate<AppLocalizationsData> {
constAppLocalizationsDelegate();
@overrideboolisSupported(Locale locale) => localizedLabels.containsKey(locale);
@overrideFuture<AppLocalizationsData> load(Locale locale) =>
SynchronousFuture<AppLocalizationsData>(localizedLabels[locale]!);
@overrideboolshouldReload(AppLocalizationsDelegate old) => false;
}
3. Generate your localizations
Run the following command to generate a lib/localization.g.dart file :
flutter packages pub run build_runner build
4. Configure your app
Update your Flutter app with your newly created delegate :
final labels = AppLocalizations.of(context);
print(labels.dates.month.february);
print(labels.templated.hello(firstName: "World"));
print(labels.templated.contact(Gender.male, lastName: "John"));
Regeneration
Because of the caching system of the build_runner, it can't detect if there is a change on the distant sheet and it can't know if a new generation is needed.
The version parameter of the @SheetLocalization annotation solves this issue.
Each time you want to trigger a new generation, simply increment that version number and call the build runner again.
then each supported language code ("en", "fr", ...)
Following rows for labels
Column 0 : the label key (can be a hierarchy, separated by dots)
then each translation based on language code of the column
Ignoring a column
Sometimes you may need to add comments for translators. For this, simply add a column with a name between parenthesis and the column will be completely ignored by the generator.
Example :
Key
(Comments)
fr
en
example.man(Gender.male)
This is a man title on home page
homme
man
example.man(Gender.female)
This is a woman title on home page
femme
woman
Conditionals
It is pretty common to have variants of a label based on a condition (for example: Genders, Plurals, ...).
Simply duplicate your entries and end them with (<ConditionName>.<ConditionCase).
You can also add one of the compatible types (int, double, num, DateTime) to the parameter by suffixing its key with :<type>.
/// Sheet
values.price, "The price is {{price:double}}\$"/// Codeprint(labels.values.price(price: 10.5));
Formatted parameters
You can indicate how the templated value must be formatted by ending the value with a formatting rule in brackets [<rule-key>]. This can be particulary useful for typed parameters.
The available formatting rules depend on the type and generally rely on the intl package.
I find the Flutter internationalization tools not really easy to use, and I wanted a simple tool for sharing translations. Most solutions also use string based keys, and I wanted to generate pure dart code to improve permormance.