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

패키지 상세v1.2.0

multi_language_json

Flutter 애플리케이션에 다국어를 지원하는 간단한 방법!

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
39
좋아요
21
Pub 점수
140

패키지 설치

flutter pub add multi_language_json

패키지 개요

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

multi_language_json은 애플리케이션에서 다국어 지원을 간소화하기 위해 설계된 Flutter 패키지입니다. JSON 파일을 사용하여 번역을 효율적으로 관리할 수 있게 해주며, 언어를 동적으로 전환하는 것을 쉽게 만듭니다. 이 패키지는 Android, iOS, Web, macOS, Windows, Linux 등 모든 주요 플랫폼을 지원하여 환경에 관계없이 일관된 로컬라이제이션을 보장합니다. 최소한의 설정과 직관적인 통합으로 Flutter 앱의 국제화 프로세스를 간편하게 만들어 줍니다.

사용 사례

  • 앱 로컬라이제이션
  • 다국어 지원
  • 동적 언어 전환
  • 번역 관리
  • 크로스 플랫폼 앱

주요 기능

  • JSON 기반 번역 파일
  • 언어 전환 쉽게
  • Platform-agnostic
  • 최소 구성
  • 모든 플러터 플랫폼을 지원합니다

적합한 대상

  • 플러터 개발자
  • 다중 언어를 필요로 하는 앱
  • 자주 번역이 업데이트되는 프로젝트
  • 로컬라이제이션 워크플로를 관리하는 팀
  • 간단한 i18n 솔루션을 찾는 개발자

고려 사항

  • 수동 JSON 파일 관리가 필요합니다
  • 내장된 번역 편집 도구 없음
  • 정적 텍스트 번역에 한정
  • 대규모 번역 팀에는 적합하지 않습니다
  • 자동 백업 언어 처리 없음

원본 README

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

Stream Language

Check it out at Pub.Dev

A simple way to support your Flutter application with multiple languages!

Gravar_2020_04_12_05_50_22_436

Help Maintenance

I've been maintaining quite many repos these days and burning out slowly. If you could help me cheer up, buying me a cup of coffee will make my life really happy and get much energy out of it.

Buy Me A Coffee

Getting Started

First you need create a directory in your main folder with name lang like this:

Screenshot_20

Note that each json file must have its language and country code as its name. Remember to add them to your pubspec:

Screenshot_21

In the code, to start you must first create an object with the following attributes: final language = MultiLanguageBloc( initialLanguage: 'pt_BR', defaultLanguage: 'pt_BR', commonRoute: 'common', supportedLanguages: [ 'en_US', 'pt_BR' ] );

MultiLanguageBloc is a singleton, after the first start, it will have the same attributes.

CommonRoute:

Here you enter the key within the language that contains words that can be used on more than one screen as in the example below:

Screenshot_22

The first time you use firebase language you should do this:

final language = MultiLanguageBloc(
   initialLanguage: 'pt_BR',
   defaultLanguage: 'pt_BR',
   commonRoute: 'common',
   supportedLanguages: [
     'en_US', 'pt_BR'
   ]
);

@override
Widget build(BuildContext context) {
  return MultiLanguageStart( // # Use this widget to init languages, this will only be necessary once, after that you will only use the 'MultiStreamLanguage' widget
    future: language.init(), // # Here you call the method to init
    builder: (c) => MultiStreamLanguage(
      screenRoute: ['home'],
      builder: (context, data) => Scaffold(
        appBar: AppBar(
          title: Text(d.getValue(route: ['title'])),
        ),
        body: Center(
          child: RaisedButton(
            child: Text(data.getValue(route: ['btn'])),
            onPressed: () => language.showAlertChangeLanguage(
              context: context,
              title: data.getValue(
                route: ['dialog', 'title'],
                inRoute: false
              ),
              btnNegative: data.getValue(
                  route: ['dialog', 'btn_negative'],
                  inRoute: false
              )
            ),
          ),
        ),
      )
    )
  );
}

From the next you start using only the MultiStreamLanguage widget, the first one is needed because the first app should load all language and start the default language from the user's mobile language.

Widget MultiStreamLanguage

ScreenRoute

This is where the magic happens, as a parameter it receives the screen route within the language key, see that in the code above is as: screenRoute: ['home'], in json it looks like this:

Screenshot_23

If the route were a node within 'home' you would go something like this: screenRoute: ['home', 'route_inside_home']

[Very Important] Builder -> Data

Here is the parent object to access the texts, for that use the getValue method that has route as parameter, here it will work like ScreenRoute, its second parameter is inRoute, if true, the passed route will be traveled inside the path gives wheel informed in ScreenRoute, if false, it will look in the parent route, that is, in the beginning of json, ex:

if i called data.getValue(route: ['my_route'], inRoute: true/false);

Screenshot_23

with inRoute true:

It will return: B

with inRoute false:

It will return: A

Another very interesting point, if the past route does not exist in the current language, it will search in the standard language, and if it does not exist there, it will return a string with the text 'NULL', ex:

Gravar_2020_04_12_05_49_28_636~1

Changing Language

For this, every language node must have a child named config with the following attributes:

Screenshot_18

The title key is what will appear as the language name in the dialog you select.

After that you can call the method:

language.showAlertChangeLanguage(
    context: context,
    title: 'title',
    btnNegative: 'text'
)

This will show an alert dialog like this (Language and flag listing is done automatically from the data passed in the config node):

Screenshot_19

To change the language programmatically, just call this method passing as the language prefix ex:

language.changeLanguage('pt_BR');

카테고리

의존성

의존성 목록 2 개

소스 저장소

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

아직 데이터가 없습니다.