Git Product home page Git Product logo

flutter-strings-to-arb's Introduction

flutter-strings-to-arb

Flutter’s internationalisation is a solid approach to support localisation in the apps. However there is no easy way to extract strings from the dart codes into the arbs. The Flutter Intl plugin supports exporting strings using the IDE’s context menu but that is only available for single strings. So I created a code we can run to extract almost all strings from the codes.

Technical Details

What it does is that it searches for double and single qouted strings in a line and fetches the word/sentence in between.

Extract Strings to arb

  • Open strings_to_arb.dart
  • Make sure write = true at line 67.
  • In Android studio , run strings_to_arb by right clicking -> run
  • This will show the list of strings that are still present in the Dart files, keep in mind some strings do not need to be copied. It will copy all the strings to the outputFilename mentioned in the file, by default it is intl_en.arb.dart.

Find all strings present in the codes

  • Open strings_to_arb.dart
  • Make sure write = false at line 67.
  • In Android studio , run strings_to_arb by right clicking -> run
  • This will show the list of strings that are still present in the Dart files, keep in mind some strings do not need to be copied. Install Flutter Intl plugin in Android Studio. After installing that plugin, it should show an extract to arb view action whenever we are over a string. (the left bulb icon) . Use that to extract all remaining strings.

Skip Folders and Files that you want to manually extract

  • Modify the variable skipFiles at line 71
  • To skip folders: add the names of the folders in the strings_to_arb.dart
  • To skip files: add the name of the file along with its extension.
  • var skipFiles = ["strings_to_arb.dart", "models", "generated"];
  • The above code with skip the strings_to_arb.dart file and ‘models’ and ‘generated’ folders.

flutter-strings-to-arb's People

Contributors

nabil6391 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

flutter-strings-to-arb's Issues

Unhandled Exception: FileSystemException

Getting error while executing script on windows : Creation failed, path = '/lib' (OS Error: Read-only file system, errno = 30)

I/flutter (21312): sada I/flutter (21312): Directory: '/lib' I/flutter (21312): Directory: '/lib/l10n' E/flutter (21312): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: FileSystemException: Creation failed, path = '/lib' (OS Error: Read-only file system, errno = 30) E/flutter (21312): #0 _Directory.createSync (dart:io/directory_impl.dart:129:7) E/flutter (21312): #1 main (package:practise/strings_to_arb.dart:59:17) E/flutter (21312): #2 _runMain.<anonymous closure> (dart:ui/hooks.dart:129:23) E/flutter (21312): #3 _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:296:19) E/flutter (21312): #4 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:189:12)
@nabil6391

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.