translation_string_extractor 0.0.1+2 copy "translation_string_extractor: ^0.0.1+2" to clipboard
translation_string_extractor: ^0.0.1+2 copied to clipboard

Extracts .tr and .tr() strings from a project into a JSON file or returns a Map

Translation String Extractor #

Extracts strings marked for translation with .tr or .tr() and writes them into JSON file or returns a Map.

The tool will ignore file names ending in .g.dart.

Input:

import 'package:flutter/material.dart';
import 'package:get/get.dart';

class TestClass extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Column(children: [
      Text('Hello'.tr),
      Text("""World""".tr),
    ]);
  }
}

Output:

{
  "Hello": "Hello",
  "World": "World"
}

Installation #

dev_dependencies:
  translation_string_extractor: <latest>

Or install the package globally:

dart pub global activate translation_string_extractor

Usage #

As a dev dependency:

dart run translation_string_extractor:extract -d=lib -o=locale.json

Globally:

translation_string_extractor -d=lib -o=locale.json

Public Signature:


TranlationStringExtractor ...

static void extractStrings(String directory, String outputFile);

static Map<String, String> read(String directory) {
  SplayTreeMap<String, String> map = SplayTreeMap<String, String>();

static void write(Map<String, String> map, String outputFile);

Issues #

https://github.com/xErik/translation_string_extractor/issues

License #

This package is licensed under the MIT license.

0
likes
140
pub points
7%
popularity

Publisher

verified publishernovelplotter.com

Extracts .tr and .tr() strings from a project into a JSON file or returns a Map

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

args

More

Packages that depend on translation_string_extractor