arb_translator_gen_z 2.0.0 copy "arb_translator_gen_z: ^2.0.0" to clipboard
arb_translator_gen_z: ^2.0.0 copied to clipboard

Modern CLI tool for translating ARB localization files into 100+ languages with enterprise features like retry logic, rate limiting, and validation.

example/example.dart

// Copyright (c) 2024, Saurav Khanal. All rights reserved.
// Use of this source code is governed by a MIT license that can be
// found in the LICENSE file.

/// Main example demonstrating basic usage of arb_translator_gen_z.
///
/// This example shows:
/// - Basic translation of ARB files
/// - Configuration options
/// - Error handling
library;

import 'dart:io';
import 'package:arb_translator_gen_z/arb_translator_gen_z.dart';

Future<void> main() async {
  print('🌍 ARB Translator Gen Z - Basic Example');
  print('======================================\n');

  try {
    // Create translator instance with default configuration
    final config = TranslatorConfig();
    final translator = ArbTranslator(config);

    // Create sample ARB file if it doesn't exist
    final sampleArbFile = File('app_en.arb');
    if (!await sampleArbFile.exists()) {
      await sampleArbFile.writeAsString('''
{
  "@@locale": "en",
  "appTitle": "Hello World",
  "@appTitle": {
    "description": "The title of the application"
  },
  "welcomeMessage": "Welcome to our app!",
  "@welcomeMessage": {
    "description": "Welcome message shown to users"
  },
  "buttonText": "Get Started",
  "@buttonText": {
    "description": "Text for the main action button"
  }
}
''');
      print('βœ… Created sample ARB file: ${sampleArbFile.path}');
    }

    // Translate to multiple languages
    final targetLanguages = ['es', 'fr', 'de', 'ja'];
    print('πŸ”„ Translating to: ${targetLanguages.join(', ')}');

    for (final lang in targetLanguages) {
      print('\nπŸ“ Translating to $lang...');

      final outputPath = await translator.generateArbForLanguage(
        sampleArbFile.path,
        lang,
      );

      print('βœ… Translation complete: $outputPath');
    }

    print('\nπŸŽ‰ All translations completed successfully!');
    print('πŸ“ Check the generated ARB files.');
  } catch (e) {
    print('❌ Error: $e');
    exit(1);
  }
}
1
likes
150
points
47
downloads

Publisher

unverified uploader

Weekly Downloads

Modern CLI tool for translating ARB localization files into 100+ languages with enterprise features like retry logic, rate limiting, and validation.

Repository (GitHub)
View/report issues

Topics

#flutter #i18n #arb #translation #cli

Documentation

Documentation
API reference

Funding

Consider supporting this project:

github.com

License

MIT (license)

Dependencies

args, cli_util, http, logging, path, retry, yaml

More

Packages that depend on arb_translator_gen_z