get_translations_generator 1.0.5 copy "get_translations_generator: ^1.0.5" to clipboard
get_translations_generator: ^1.0.5 copied to clipboard

A CLI for generate getx translations from csv.

Get Translations Generator #

Installation CLI #

dart pub global activate get_translations_generator

Run CLI #

dart pub global run get_translations_generator <CSV file path> <output Dart file path>

Example CLI #

dart pub global run get_translations_generator input.csv output.dart

Example file csv for generate translations #

th_TH,greetings,สวัสดี
en_US,greetings,hello
th_TH,search,ค้นหา
en_US,search,search

Example Result file get transaltions #

import 'package:get/get.dart'; 

class Translate extends Translations {
  @override
  Map<String, Map<String, String>> get keys => {
    'th_TH': {
      'greetings': 'สวัสดี',
      'search': 'ค้นหา',
      'weather': 'สภาพอากาศ',
    },
    'en_US': {
      'greetings': 'hello',
      'search': 'search',
      'weather': 'weather',
    },
  };
}


class TranslateKeys {
    static const String greetings = 'greetings';
    static const String search = 'search';
    static const String weather = 'weather';
} 

Example Usecases #

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

  @override
  Widget build(BuildContext context) {
    return GetMaterialApp(
      title: 'Example App',
      localizationsDelegates: const [
        GlobalMaterialLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate,
      ],
      supportedLocales: const [
        Locale('en', 'US'), // English
        Locale('th', 'TH'), // Thai
      ],
      locale: const Locale('en', 'US'),
      translations: Translate(),
      home: Example(),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Example'),
      ),
      body: Center(
        child: Text(TranslateKeys.greetings.tr),
      ),
    );
  }
}

0
likes
120
points
186
downloads

Publisher

unverified uploader

Weekly Downloads

A CLI for generate getx translations from csv.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

csv, path

More

Packages that depend on get_translations_generator