Comments (6)
Hi @beeing,
Do you have an example/more informations about what you actually trying to do ?
I don't get if you're talking about extracting text from your HTML to a JSON file, or about feeding frenchkiss.js with an imported JSON file.
from frenchkiss.js.
Hi, I'm currently using ngx-translate which is similar but for angular.
Based on your example, we need to set the language first with string template.
set('en', {
hello: 'Hello {name} !',
});
Then use the template by calling:
t('hello', { name: 'John' }); // => 'Hello John !'
However, a natural workflow is to do the following:
t('Hello {name}', { name: 'John' })
Then we will need a CLI (command line utility) to extract all the texts from t().
Example above would return:
{
"Hello {name}": ""
}
We can then duplicate this JSON as en.json or any {locale}.json with different key values.
I hope you get the idea.
from frenchkiss.js.
Just to add in, when the JSON is completed, we can use:
set(locale, loadFromJsonFile)
so that t()
will use the correct string templates.
from frenchkiss.js.
I think you should take a look at i18next-scanner (or another tool).
It extracts translations from your files based on a list of function (here ['t', 'frenchkiss.t']
) then generate a json as output.
from frenchkiss.js.
You can try https://github.com/lukasgeiter/gettext-extractor. po2json or https://github.com/perch-foundation/po-loader can be used to convert the PO data.
from frenchkiss.js.
Ok, looks like this is quite the same. Perhaps can add this into README for a complete picture.
Thanks.
from frenchkiss.js.
Related Issues (12)
- "I did not bought apples!" is not English HOT 1
- [Suggestion] Change the order of parameters HOT 4
- [Suggestion] Add typescript support
- CSP compatibly HOT 3
- [Suggestion] Add support for nested objects HOT 1
- [Suggestion] pass params to onMissingKey HOT 1
- [Feature Request] Export the getCompiledCode method HOT 3
- Can the key be considered as a fallback to a language HOT 1
- Code generation from strings disallowed for this context
- Add github actions to validate PRs through the tests
- Ordinal suffix configuration
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 frenchkiss.js.