플러터:다중언어: 두 판 사이의 차이
보이기
새 문서: {{플러터}} == 개요 == <code>flutter_localizations</code> + <code>intl</code> + ARB 파일 구조로 만드는 것이 공식. == 사전 작 == === 패키지 설치 === 다음과 같은 형태로.<syntaxhighlight lang="yaml"> dependencies: flutter: sdk: flutter flutter_localizations: sdk: flutter intl: ^0.19.0 flutter: generate: true </syntaxhighlight> === 폴더 및 언어 파일 생성 === lib/l10n/app_en.arb<syntaxhighlight lang="json">{ "hello": "He... |
잔글편집 요약 없음 |
||
| 17번째 줄: | 17번째 줄: | ||
flutter: | flutter: | ||
generate: true | generate: true | ||
</syntaxhighlight> | |||
=== 코드 생성 === | |||
다음 명령을 실행하면 번역데이터 ARB 파일을 기반해석하여 dart로 자동 생성된다.<syntaxhighlight lang="bash"> | |||
flutter gen-l10n | |||
</syntaxhighlight>생성 위치<syntaxhighlight lang="text"> | |||
lib/gen_l10n/app_localizations.dart | |||
</syntaxhighlight> | </syntaxhighlight> | ||
2026년 3월 12일 (목) 02:24 기준 최신판
- 플러터:개요
- 플러터:실행
- 플러터:개념 잡기
- 권한 사용
- 위젯
- 플러터:DB연결
- 플러터:HIVE
- 플러터:Firebase(미완)
- 플러터:MySQL(미완)
- 디자인
- 편의
- 플러터:배포
- 플러터:배포(안드로이드)(미완)
- 플러터:배포(iOS)(미완)
- 플러터:참고자료
- 플러터:위젯
- 플러터:구글 AdMob(미완)
- 플러터:라이브러리
flutter_localizations + intl + ARB 파일 구조로 만드는 것이 공식.
다음과 같은 형태로.
dependencies:
flutter:
sdk: flutter
flutter_localizations:
sdk: flutter
intl: ^0.19.0
flutter:
generate: true
다음 명령을 실행하면 번역데이터 ARB 파일을 기반해석하여 dart로 자동 생성된다.
flutter gen-l10n
생성 위치
lib/gen_l10n/app_localizations.dart
lib/l10n/app_en.arb
{
"hello": "Hello",
"@hello": { // 사용되지 않는, 문자 설명용. 어디서 쓰는지 등등
"description": "Hello text"
},
"login": "Login"
}
lib/l10n/app_ko.arb
{
"hello": "안녕하세요",
"login": "로그인"
}
import 'package:flutter_localizations/flutter_localizations.dart';
import 'l10n/app_localizations.dart';
MaterialApp(
localizationsDelegates: const [
AppLocalizations.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: const [
Locale('en'),
Locale('ko'),
],
)