패키지, 저장소 및 앱 카테고리 검색

패키지 상세v2.2.0

flappy_translator

CSV 및 Excel 파일에서 Flutter 로컬라이제이션 리소스를 자동으로 생성하는 도구입니다.

AndroidiOSLinuxmacOSWindows
30일 다운로드
160
좋아요
32
Pub 점수
140

패키지 설치

flutter pub add flappy_translator

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

Flappy Translator는 CSV 및 Excel 파일에서 로컬라이제이션 리소스를 자동으로 생성하는 Flutter 패키지입니다. 구조화된 번역 데이터를 Flutter의 지역 설정 파일로 변환함으로써 국제화 프로세스를 간소화하고 수작업을 줄이며 오류를 최소화합니다. 여러 언어를 관리하는 팀에게 이상적이며, 동적 업데이트를 지원하고 기존 워크플로우에 원활하게 통합됩니다. 이 도구는 번역 일관성을 보장하며 Flutter의 로컬라이제이션 시스템에 깊은 지식이 없어도 앱 로컬라이제이션을 가속화합니다.

사용 사례

  • 로컬라이제이션 파일 생성 자동화
  • 다국어 앱 콘텐츠 관리
  • 번역 워크플로우 간소화
  • CI/CD 파이프라인과의 통합
  • 코드 변경 없이 번역 업데이트
  • 비기술 번역가와 협업하기

주요 기능

  • CSV 및 Excel 입력 형식을 지원합니다
  • 자동으로 Flutter 로컬라이제이션 파일을 생성합니다
  • 일관된 키 구조를 유지합니다
  • Flutter 프로젝트와의 간편한 통합을 가능하게 합니다
  • 명확한 오류 보고를 제공합니다
  • 번역에 대한 팀 협업을 촉진합니다

적합한 대상

  • 다국어 앱을 개발하는 개발자
  • 스프레드시트를 사용하는 현지화 팀
  • 자주 번역이 업데이트되는 프로젝트
  • 자동 빌드 프로세스를 사용하는 팀
  • 확장 가능한 국제화를 필요로 하는 앱

고려 사항

  • 올바르게 형식화된 입력 파일이 필요합니다
  • 정확성 확인을 위해 수동 검토를 권장합니다
  • 버전 관리된 번역 파일과 함께 사용하는 것이 가장 좋습니다
  • 정적 번역 데이터에 한정
  • 실시간 번역 서비스가 아님
  • 올바른 파일 인코딩에 의존합니다

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

flappy_translator

This package is discontinued and no longer maintained. No further updates, fixes or compatibility changes will be released.

Please migrate to arb_generator and Flutter's official localization tooling using flutter_localizations and intl.

Migration

ICU Placeholders

Migrate variables to ICU message syntax:

Before After
Welcome %name$s Welcome {name}
ARB Files Setup

arb_generator converts CSV translations into ARB files compatible with Flutter localization tooling.

Add the following package:

  • dart pub add --dev arb_generator

Define arb_generator package settings in pubspec.yaml:

arb_generator:
  input_filepath: "assets_dev/test.csv"
  output_directory: "lib/l10n"
  filename_prepend: "app_"

See arb_generator documentation for full example.

Flutter Localization Setup

Flutter's localization tooling generates compile-time localization delegates from ARB files.

Add the following packages:

  • flutter pub add flutter_localizations --sdk=flutter
  • flutter pub add intl:any

Enable delegate generation:

flutter:
  generate: true

in pubspec.yaml.

Add l10n.yaml file:

arb-dir: lib/l10n
template-arb-file: app_en.arb
output-dir: lib/l10n
output-localization-file: app_localizations.dart

See Flutter documentation for more information.

Generate Localization Delegates
dart run arb_generator
flutter gen-l10n
Update Delegate Usage

Use the generated AppLocalizations API instead of the old I18n API:

import '../l10n/app_localizations.dart';

Text(AppLocalizations.of(context)!.welcome('Dash')),

instead of

import 'i18n.dart';

Text(I18n.of(context).welcome(name: 'Dash')),
View Original README

A 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.

Getting Started

In order to use the flappy_translator package, please provide your translations in a CSV or Excel file. For CSV files, delimiters , and ; have been tested to work.

keys fr en en_GB de
plainText Bonjour le monde! Hello world! Hello world! Hallo Welt!
welcome Bienvenu %name$s! Welcome %name$s! Welcome %name$s! Willkommen %name$s!
favoriteColor Quelle est votre couleur préférée? What is your favorite color? What is your favourite colour? Was ist deine Lieblingsfarbe?

Localizations can be specified for a region by appending the country code.

Add dependency
dependencies:
  flutter_localizations:
    sdk: flutter
    
dev_dependencies: 
  flappy_translator: 
Define Settings

Settings for flappy_translator must set in your project's pubspec.yaml file. input_file_path is the only required parameter.

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: []
Setting Default Description
input_file_path N/A Required. A path to the input CSV/Excel file.
output_dir lib A directory to generate the output file.
file_name i18n A filename for the generated file.
class_name I18n A class name for the generated file.
delimiter , CSV files only: a delimited to separate columns in the input CSV file.
start_index 1 The column index where translations begin (i.e. column index of default language).
depend_on_context true Whether the generated localizations should depend on BuildContext
use_single_quotes false Whether the generated file should use single or double quotes for strings.
replace_no_break_spaces false Whether no break spaces (\u00A0) should be replaced with normal spaces (\u0020).
expose_get_string false The default value for whether a getString method should be exposed.
expose_loca_strings false The default value for whether a locaStrings getter should be exposed.
expose_locale_maps false The default value for whether a localeMaps getter should be exposed.
generate_comments false Whether documentation comments should be used to display translations.
comment_languages [] Languages that are displayed in the comments. Empty -> All languages are used.
Run package

Make sure that your current working directory is the project root.

flutter pub get
dart run flappy_translator
Update iOS Info.plist

For 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 file

The 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 {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      localizationsDelegates: const [
        I18nDelegate(),
        GlobalMaterialLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate,
        GlobalCupertinoLocalizations.delegate,
      ],
      supportedLocales: I18nDelegate.supportedLocals,
      home: const Home(),
    );
  }
}

Then use the generated I18n class!

class Home extends StatelessWidget {
  const Home({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('flappy_translator'),
      ),
      body: Center(
        child: Column(
          mainAxisSize: MainAxisSize.min,
          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 Localizations

Supporting 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 functionalities

Locale

Locales are specified in the top row and are expected to be given in the form en or en_US.

Default language

The column at start_index is considered the default language. This means that:

  1. If this column does not have a value, the loca key instead will be used.
  2. If another language does not have translations for a given key, the value of the default language will be used.
Keys

Each loca key must begin with a lowercase letter, after which any combinations of lowercase, uppercase, digits or underscores are valid.

Variables

In order to include variables in loca strings, they need to be written in the format %<VAR NAME>$<VAR TYPE>. Presently only integers and strings are supported as variable types.

  • %myVariable$d (d stands for an int)
  • %myVariable$s (s stands for a String)

All variables are required. Consider the key welcome from example. The generated function signature is

String welcome({
  required String name,
})

Note that if the variable's name starts with a number, the generated variable name will be var<VAR NAME>. So, for instance, %1$d would become var1.

카테고리

의존성

의존성 목록 3 개

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.