Buscar pacotes, repositórios e categorias de apps

Detalhes do pacotev1.1.1

ez_localization

Configure rapidamente e facilmente um sistema de localização poderoso em seu aplicativo Flutter.

AndroidiOSWebmacOSWindowsLinux
Downloads em 30 dias
193
Curtidas
23
Pontos Pub
150

Instalar pacote

flutter pub add ez_localization

Visão geral do pacote

Orientação gerada a partir de informações públicas. Apenas para referência.

ez_localization é um pacote Flutter que simplifica a configuração de um sistema robusto de localização, permitindo que desenvolvedores implementem internacionalização rapidamente em seus aplicativos. Ele suporta múltiplos idiomas e fornece uma API intuitiva para gerenciar traduções em Android, iOS, Web, macOS, Windows e Linux. Com mínima configuração, permite troca fluida entre locais e lida eficientemente com conteúdo dinâmico. O pacote é ideal para aplicativos voltados para públicos globais, reduzindo o código boilerplate enquanto mantém flexibilidade e escalabilidade.

Casos de uso

  • Suporte a aplicativos multilíngues
  • Gestão fácil de tradução
  • Mudança dinâmica de localidade
  • Internacionalização multiplataforma
  • Configuração simplificada de i18n
  • Localização de aplicativos para usuários globais

Principais recursos

  • Configuração mínima necessária
  • Suporta todas as principais plataformas
  • Mudança de localização embutida
  • Sintaxe de tradução limpa e legível
  • Estrutura de arquivo de tradução extensível
  • Falha automática para o idioma padrão

Indicado para

  • Desenvolvedores construindo aplicativos multilíngues
  • Equipes gerenciando fluxos de trabalho de tradução
  • Projetos que exigem integração rápida de i18n
  • Aplicativos direcionados a mercados internacionais
  • Iniciantes do Flutter aprendendo localização
  • Projetos com atualizações frequentes de idioma

Considerações

  • Requer organização adequada do arquivo de tradução
  • Ferramentas limitadas de edição de tradução integradas
  • Manuseio manual de formas plurais complexas
  • Depende das convenções corretas de nomeação de localidade
  • Sem armazenamento ou sincronização de tradução embutidos
  • Melhor usado com arquivos de tradução estruturados

README original

Snapshot do README original do repositório-fonte vinculado. Consulte o repositório para o conteúdo mais recente.

EzLocalization

This package allows you to setup a powerful localization system with ease and in only a few minutes.

Features

Here are some features:

  • Easy, lightweight, open-source.
  • MIT licensed.
  • Easily extensible.

Getting started

It only takes a few steps in order to get EzLocalization to work !
First, add the following code to your MaterialApp definition (usually in main.dart) :

EzLocalizationDelegate ezLocalization = EzLocalizationDelegate(supportedLocales: [Locale('en'), Locale('fr')]); // The first language is your default language.

return MaterialApp(
  // ...
  localizationsDelegates: ezLocalization.localizationDelegates,
  supportedLocales: ezLocalization.supportedLocales,
  localeResolutionCallback: ezLocalization.localeResolutionCallback,
);

Then you create a folder named languages in your assets directory with the defined languages in it. An example structure could be :

assets
└── languages
    ├── en.json
    └── fr.json

Here's an example of en.json :

{
  "hello": "Hello !"
}

And a translated fr.json :

{
  "hello": "Bonjour !"
}

Don't forget to add the assets in your pubspec.yml :

flutter:
  # ...
  assets:
    - "assets/languages/"

That's it ! To get your string you only have to call EzLocalization.of(context)!.get('hello').

Advanced

Extension method

With the extension method, it's even easier to get a localized string ! The only thing you have to do is to replace EzLocalization.of(context)!.get('key') by context.getString('key').

You may have to manually import EzLocalization in your file.

Builder widget

EzLocalization provides a builder widget called EzLocalizationBuilder. You can use it as such :

const EzLocalizationBuilder(
  delegate: EzLocalizationDelegate(
    supportedLocales: [
      Locale('en'),
      Locale('fr'),
      Locale('es'),
    ],
  ),
  builder: (context, localizationDelegate) => MaterialApp(
    title: 'Beautifully localized app',
    home: MyMainWidget(),
    localizationsDelegates: localizationDelegate.localizationDelegates,
    supportedLocales: localizationDelegate.supportedLocales,
    localeResolutionCallback: localizationDelegate.localeResolutionCallback,
  ),
);

It has two advantages :

  • It helps reducing boilerplate.
  • You can dynamically change the current locale using EzLocalizationBuilder.of(context)!.changeLocale(yourLocale).
Nested strings

You can nest translation strings as such :

{
  "tabs": {
    "home": "Home"
  }
}

And it can be access using EzLocalization.of(context)!.get('tabs.home').

Format arguments

In your translation string, you may add arguments using {} :

{
  "greeting": "Hello {target}, my name is {me} !"
}

You can then fill them with EzLocalization.of(context)!.get('greeting', {'target': 'John', 'me': 'Bob'}). Also, instead of a map you can pass a list and get your arguments by their indexes.

Change the files path

You can change from the default path of assets/languages/$languageCode.json by passing getPathFunction to EzLocalizationDelegate. You will then have to provide a valid asset path according to the specified locale.

Don't forget to update your assets entry in your pubspec !

Updating the iOS app bundle

See the official flutter.dev documentation about updating the iOS app bundle.

Contributing

You have a lot of options to contribute to this project ! You can :

Categorias

Repositório-fonte

Projetos que usam este pacote

Ainda não há dados.