Comments (6)
I worked with i18next and its adapters to angular a lot in the past. To me it feels really slick and natural. If you take knockout.punches into account you could solve it through piping as in angular:
<span>{{'general.greet' | translate::username}}</span>
Though the way the filter parameters are passed in ko.punches could be improved like so:
<span>{{'general.greet' | translate: {name: username} }}</span>
That way you would have named parameters and you wouldn't introduce a new syntax, instead you'd have an ordinary JavaScript object.
Number and Date formatting is not provided by i18next afaik.
edit: apparently it does: http://i18next.com/translate/formatting/
from tko.
Given a binding translator (like i18next), there are three ways I think it could be employed:
- A binding provider (i.e.
tko.provider.i18n
) - converts text nodes by running them through a binding-translator based on some criteria/regex/etc - an explicit i18n binding works like, or pairs with, the
text
binding - one or more i18n filters that pluralize/etc
A sane strategy for one or more of these probably requires delving into what others do.
from tko.
I wouldn't suggest using an explicit i18n-binding since it limits the possibilities to work with i18n. Think of attribute-values like placeholder
or title
. Think of combining multiple keys.
The rest is totally cool :)
from tko.
To limit documentation effort, and despite API inconsistency, I'd suggest a provider of the exactly same syntax as https://github.com/i18next/jquery-i18next with the extra requiment that data-i18n-options might be subscribable and trigger a new translation when changing. Also this syntax is supported by https://github.com/i18next/i18next-parser
from tko.
@miellaby those are fantastic suggestions, thank you
from tko.
from tko.
Related Issues (20)
- Deprecate unused npm packages HOT 2
- Convert legacy documentation
- Replace hard-coded parser unicode identifier detection with RegExp HOT 3
- optionsText with a lambda value fails to resolve the function argument HOT 2
- Add preventDefault to event handler options HOT 5
- Incorrect tree with multiple 'or' operators in parser HOT 1
- Unable to load from an ES module HOT 1
- TypeError: Cannot set properties of undefined (setting 'ko') HOT 1
- Re-enable tests on builds/knockout HOT 2
- `options.bindingGlobals` can't be changed at runtime
- Revamp www.tko.io
- Fix typing of the Observable<boolean> HOT 5
- Change mappingHelpers `objectLookup` from an O(n) array to O(1) Map
- Fix the build / exports in package.json
- Build @tko/build.reference into the `tko` package
- Server side render SSR support
- How to build and import TKO-beta as a bundled library. HOT 3
- [beta1.3] ESM support HOT 3
- Writable computed out of sync
- If you have multiple || (ORs), you need parentheses, otherwise it fails silently HOT 4
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 tko.