translatron 0.0.6 copy "translatron: ^0.0.6" to clipboard
translatron: ^0.0.6 copied to clipboard

outdated

VERSION - NOT FOR LIVE OR PROD USAGE! A package for translations, from api calls. Only use if your backend team can provide the nedded api urls!

Welcome to Translatron! #

##!BETA VERSION - NOT FOR LIVE OR PROD USAGE!

Description #

Comming soon...

Usage #

Comming soon...

Initilazion #

Basic Initilazion

    void  main() async {
		await  Translatron.init(
			hostname:  "https://example.com",
			versionPath:  "/api/translation/version",
			translationsPath:  "/api/translation/translations",
		);
	]);

Initilazion with custom supported languages

    void  main() async {
		await  Translatron.init(
			hostname:  "https://example.com",
			versionPath:  "/api/translation/version",
			translationsPath:  "/api/translation/translations",
			supportedLocales:  const [
				Locale('hu'),
				Locale('en'),
			],
		);
	]);

Initilazion with custom supported languages and custom api headers

    void  main() async {
		await  Translatron.init(
			hostname:  "https://example.com",
			versionPath:  "/api/translation/version",
			translationsPath:  "/api/translation/translations",
			supportedLocales: const [
				Locale('hu'),
				Locale('en'),
			],
			apiHeaders: const {
				"Authorization" : "Bearer $token",
				"Content-Type: application/json"
			}
		);
	]);

Add the custom delegate to app

return  MaterialApp.router(
	title:  'DemoApp',
	localizationsDelegates:  const [
		Translatron.delegate,
		GlobalMaterialLocalizations.delegate,
		GlobalWidgetsLocalizations.delegate,
		GlobalCupertinoLocalizations.delegate,
	],
	//To change to your state management
	locale: Provider.of<LocaleProvider>(context,  listen:  true).getlocale, 
	supportedLocales:  Translatron.getSupportedLocales,
);

Demo provider

class  LocaleProvider  with  ChangeNotifier {
	Locale?  locale  =  Translatron.getSelectedLanguageLocale;
	
	Locale?  get  getlocale {
		return  locale;
	} 

	void  changeLocale(Locale  newLocale) {
		locale  =  newLocale;
		Translatron.setSelectedLanguageLocale  =  locale!;
		notifyListeners();
	}
}

Language change with provider

Provider.of<LocaleProvider>(context,  listen:  false)
.changeLocale(const  Locale('hu',  'HU'));

Functions #

Translate, returns string

Translatron.of(context)!.translate("translation.key");

Return if language is active, returns bool

Translatron.isLanguageActice('en');

Returns the supported locales in List of Locale

Translatron.getSupportedLocales;

Returns the selected Language Locale, in some cases nullable

Translatron.getSelectedLanguageLocale;

Sets the selected Language Locale, in some cases nullable

Translatron.setSelectedLanguageLocale  =  locale!;
3
likes
0
points
54
downloads

Publisher

unverified uploader

Weekly Downloads

VERSION - NOT FOR LIVE OR PROD USAGE! A package for translations, from api calls. Only use if your backend team can provide the nedded api urls!

Homepage
Repository (GitHub)
View/report issues

Documentation

Documentation

License

unknown (license)

Dependencies

flutter, http, path_provider, shared_preferences

More

Packages that depend on translatron