ttag-org / babel-plugin-ttag Goto Github PK
View Code? Open in Web Editor NEW:blue_book: ttag - library for extracting and resolving gettext translations extract es6 localization
Home Page: https://ttag.js.org
License: MIT License
:blue_book: ttag - library for extracting and resolving gettext translations extract es6 localization
Home Page: https://ttag.js.org
License: MIT License
how to handle multiline templates (remove tabs, \n ?)
this should work
t`hello ${user.name}`
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?
Regarding this issue - ttag-org/ttag#41 we need to change how plugin behaves by default.
['c-3po', {}]
or ['c-3po']
it must not resolve default locale.{ resolve : { translations : 'default' }}
is present.Docs:
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'] }
{
resolve: {locale: 'en-us', resolveFuncs: ['ngettext'] }
}
will resolve only ngettext (is useful for default locale translations).
this should throw:
gettext(`fdjkfldkj ${a}`)
This plugin can use validators from src/extracts
Fix issue with multiple references. For now there is only 1 reference even when string appears multiple times in the code.
The idea is to have more realistic test suite that will check plugin on some bunch of files with lots of cases.
make that kind of plural form working
throw validation error when tagged functions are used as simple functions.
This can confuse msgen utility (for copying msgid and msgstr)
this should be considered as warning
gettext('');
t``;
nt(a)``;
gettext(`fjdkls`)
gt`first ${ a } then ${ b }`
```
should be extracted to:
'first ${ 0 } then ${ 1 }'
with additional comment like
# first ${ a } then ${ b }
some kind of comment in file that allows to skip file parse
/* skip c-3po */
for now logic that checks if file reference exists is slow because it uses string.match on each iteration step. I think this can be optimized by rewriting that code part with different datastructures.
https://github.com/c-3po-org/babel-plugin-c-3po/blob/master/src/po-helpers.js#L26
gt`first ${ a } then ${ b }`
should be extracted as
msgid: 'first ${ 0 } then ${ 1 }'
For now c-3po will throw if some validation fails and will skip checking the rest of file.
The idea is to collect all validation errors, and throw them only after the whole file is parsed.
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'
}
}
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 | }
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.
ngettext(lazy`www`, lazy`wwws`, n)
just use
{
extract: 'output.pot'
}
When translation is not found by msgid we should provide warning to the console.
Provide special option that will throw exception in that case (for production builds).
remove redundant fixtures (jus use expect.to.contain)
test_resolve_*
The :c tag usage from here - https://github.com/eslachance/node-i18n
this should not pass validation
t` `
t`${a} ${b}`
t` ${b}
${c}`
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'
sort output translations in .pot file by filename or sort by location
msgid "Телефон для обратной связи. Например: ${ 0 }"
msgstr "Телефон для зворотного зв'язку. Наприклад: $ {0}"
Make filepath relative to project root.
gettext, t, nt
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.
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()}`
must throw exception if has invalid number of plural forms to ngettext.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.