Comments (7)
And how would you make plural sentences ? What would be the result of the gulp file ? You do realize that the translations files are plain JS object and there is nothing to « optimize » (if that's what you mean)
from i18n-node-2.
I guess all possibilities need to be extracted at once, plurals included. Gettext does it, the extraction happens beforehand, the plain JS object should have all strings that need to be translated. Think of the following scenarios in a large production app:
Scenario 1:
- Write i18n strings in app
- Before deployment, open every single page possible to get all strings to the translation file.
- Do it for multiple languages
- Go to translation files and translate.
- Deploy to production (or stage).
Scenario 2:
- Write i18n strings in app
- Before deployment, run gulp script to extract all translation strings.
- Go to translation files and translate.
- Deploy to production (or stage).
Which one do you prefer?
from i18n-node-2.
I guess you don't know how i18n-node-2 works so. If you would have read a bit the code, you would have seen this line (https://github.com/jeresig/i18n-node-2/blob/master/i18n.js#L59) and so files are loaded once at the beginning.
And you mention gulp to extract translations and store them where ? Gulp can't pass data to the app and there would be no interest to that as the lib does the same thing
from i18n-node-2.
I'm not discussing the loading of the translation files on runtime, I'm discussing extracting the translation strings from the app.
i18n.__('Hello %s;', 'world'); -> "Hello %s": "Olá %s" (on locales/pt.js)
This (i18n.__('Hello %s;', 'world');
) is saved to file (locales/pt.js
) when the string is requested. So you have to request all i18n.__(...)
to get all strings in locales/pt.js
.
This is the line you want: https://github.com/jeresig/i18n-node-2/blob/master/i18n.js#L405
This seems silly. I'm not sure you know how gettext works, but you can extract all __(...)
beforehand, and translate them all at once on the .po
files. It even clears out deprecated strings from the translation files.
from i18n-node-2.
i18n-node-2 does not work at all like gettext. Not at all. There is no string extraction.
Using gettext you have to analyze the sourcecode first to extract _
function calls.
i18n-node-2 does not do anything like it as it just loads a json file and match the key to the value directly.
If you want something closer to gettext, you might check other libraries like i18nnext-conv.
from i18n-node-2.
He didn't ask if it was similar to gettext, he didn't ask if it was only possible to use Gulp.
He simply asked if it's somehow possible to extract all the strings automatically, without manually visiting every single page.
Which would be extremely, insanely useful. This library is pretty much a pain for any larger project.
from i18n-node-2.
@fjeddy Yet, I don't see how i18n-node-2 is or should be related to Gulp. It was never meant for this
from i18n-node-2.
Related Issues (20)
- Support language fallbacks HOT 4
- Requesting changelog for npm version 0.7.0 HOT 2
- How to access i18n object in React components? HOT 1
- Feature Request: override current language manually HOT 2
- Did module create tmp files?
- What is the proper way to call i18n-2 accross main.js and renderer.js HOT 1
- i18n should be silent by default HOT 2
- Using i18n in js files HOT 3
- Uncaught ReferenceError: __ is not defined HOT 3
- unexpected error writing files HOT 1
- Large HB project, seems to write to JSON file over and over even with no changes HOT 6
- Issue with getting value from i18n.__("Hello") HOT 3
- The sprintf package is deprecated in favor of sprintf-js HOT 2
- setLocaleFromQuery() isn't working HOT 1
- New strings go to user-defined language
- When in Dev Mode JSON is overwritten when accidentally invalidating the JSON language file.
- Problem merging locale file with base file
- Access to the i18n outside of a request
- i18n-2 upd
- how to add support for ICU Format
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from i18n-node-2.