Google 시트에서 로컬라이제이션 파일을 생성하기 위한 어노테이션을 제공하는 플러터 패키지입니다. 개발자들이 협업 기반의 스프레드시트 워크플로우를 통해 번역을 관리하고 변경 사항을 자동으로 Dart 코드로 동기화할 수 있습니다. 시트 데이터를 앱 문자열에 직접 연결함으로써 국제화 프로세스를 간소화하며, 다중 언어를 지원하고 flutter_sheet_localization_generator와 통합하여 코드 생성을 가능하게 합니다. 수동 문자 처리 없이 중앙 집중식이고 버전 관리 가능한 번역 관리를 필요로 하는 팀에게 이상적입니다.
사용 사례
Google 시트를 통한 다국어 앱 콘텐츠 관리
로컬라이제이션 파일 생성 자동화
협업 번역 워크플로우
개발 팀 간 번역 동기화
수동 문자열 관리 오류 감소
주요 기능
로컬라이즈된 문자열을 정의하기 위한 주석
Google 시트와의 통합
자동 코드 생성
다중 로케일 지원
번역 업데이트와 실시간 동기화
적합한 대상
번역에 Google 시트를 사용하는 팀
확장 가능한 i18n이 필요한 프로젝트
자동화된 현지화를 찾는 개발자
글로벌 청중을 대상으로 하는 앱
자주 번역이 업데이트되는 프로젝트
고려 사항
Google Sheets API에 액세스해야 합니다
코드 출력을 위해 생성기 패키지에 의존합니다
적절한 시트 구조 설정이 필요합니다
민감한 데이터는 신중하게 다뤄야 합니다
동기화를 위해 네트워크 연결이 필요합니다
원본 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.