Git Product home page Git Product logo

ttag-org / babel-plugin-ttag Goto Github PK

View Code? Open in Web Editor NEW
28.0 6.0 27.0 1.33 MB

:blue_book: ttag - library for extracting and resolving gettext translations extract es6 localization

Home Page: https://ttag.js.org

License: MIT License

JavaScript 96.61% Makefile 3.07% Shell 0.32%
babel-plugin gettext po-files localization i18n javascript template-literals resolves-translations translation language

babel-plugin-ttag's People

Contributors

alecf avatar aleksandergurin avatar alexmost avatar cjies avatar dannydelott avatar dependabot[bot] avatar dhoko avatar jorrit avatar manonthemat avatar manuel-woelker avatar mrorz avatar oleksandr-kuzmenko avatar piecyk avatar ramyapayyavula avatar slavikovbasa avatar thoulsadoom avatar uriesk avatar zentiman93 avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

babel-plugin-ttag's Issues

multiline

how to handle multiline templates (remove tabs, \n ?)

deal with multiline

find out how plugin extracts multiline strings like

function test() {
    t`some random text
    some random word`
}

indentations? How backslash at the end of the string works?

fix default resolve behaviour

Regarding this issue - ttag-org/ttag#41 we need to change how plugin behaves by default.

  • With no configuration at all
    ['c-3po', {}] or ['c-3po'] it must not resolve default locale.
  • resolve default locale when { resolve : { translations : 'default' }} is present.
  • Enable validation by default.

Docs:

resolve/extract visibility

add config that will specify which functions are extracted/resolved globally (without import c-3po) and which are extracted only if there is (import or require 'c-3po' in file).

discover: { withoutImport: ['gettext'], withImport: ['t', 'nt'] }

multiple references

Fix issue with multiple references. For now there is only 1 reference even when string appears multiple times in the code.

plural=0

make that kind of plural form working

skip functionality

some kind of comment in file that allows to skip file parse

/* skip c-3po */

simplify resolve config

for now there is resolve and locales attributes inside resolve config.
Proposition is to have just resolve.
Something like

{ 
  resolve: 'uk.po'
}

instead of:

{
   resolve: { locale: 'uk' },
   locales: {
     uk: 'uk.po'
   }
}

allow simple strings inside ngettext

Need to think about this kind of plurals, maybe it's better to omit template literals where we don't need them.

ERROR in ./src/ngettextDemo.js
Module build failed: SyntaxError: Cannot read property 'forEach' of undefined

  20 |                 </div>
  21 |                 <button onClick={this.countInc}>{ t`Click me` }</button>
> 22 | 		<div>{ngettext(msgid`test`, 'tests', n)}</div>
     | 		      ^
  23 |             </div>
  24 |         )
  25 |     }

Should throw exception when variable names doesn't match

When resolving po files containing errors in variable names, babel plugin should throw an error.

For instance:

msgid "Created at ${ createdAtStr }"
msgstr "作成日 ${ cratedAtStr }"  # typo here

Currently the po file above will cause ReferenceError late at runtime.

fix for ngettext resolve

For some reason there can be not enough plural forms in .po file for current locale. For now it will fail with something like 'can not read property of undefined'

add sorting option

sort output translations in .pot file by filename or sort by location

discover c-3po functions by require

for now c-3po functions are discovered only by imports, but it is also necessary to discover them by require to make everything work on the backend side.

Validate template expressions

As soon as we will expose our formatted strings to translators, we should ensure that there is no complex expressions inside literals.
Allowing only variables like:
gt`hello ${ name }`
but not
gt`hello ${ user.getName() + user.getSurname()}`

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.