Comments (5)
OK - found the solution - I need to add this namespace manually - this isn't very clearly documented as the file links to another module - could it not be jiggled to work with the default of "one", "other", "zero" ?
from counterpart.
I wasn't able to figure it out. Wtf, how does this damn thing works? The documentation around this is really bad.
What should be in counterpart.pluralize ?
from counterpart.
I do something like this:
const localeDefaults = {
counterpart: {
pluralize: (entry, count)=> entry[
(count === 0 && 'zero' in entry)
? 'zero' : (count === 1) ? 'one' : 'other'
],
formats: {
date: {
'default': '%a, %e. %b %Y',
'long': '%A, %e. %B %Y',
'short': '%d.%m.%y'
},
time: {
'default': '%H:%M',
'long': '%H:%M:%S %z',
'short': '%H:%M'
},
datetime: {
'default': '%a, %e. %b %Y, %H:%M',
'long': '%A, %e. %B %Y, %H:%M:%S %z',
'short': '%d.%m.%y %H:%M'
}
}
}
}
const nlJSON = Object.assign(
require('./locales/phrase.nl.json'), localeDefaults
)
counterpart.registerTranslations('nl', nlJSON);
from counterpart.
Thank you kindly, sir!
from counterpart.
After struggling with this problem a bit (as my translations are in a json file, and functions are not serializable), I've found a simpler solution (one line) to this:
const translator = new Counterpart.Instance();
availableLanguages.forEach((currentLocale) => {
translator.registerTranslations(currentLocale, translations[locale]);
});
translator.setLocale(locale);
// That's it! Just add that line and all locales will use Counterpart's default
// English locale's pluralize function. :)
translator.setFallbackLocale('en');
from counterpart.
Related Issues (20)
- Emit Event when translation is not found HOT 3
- problem with html content that contains a "%" HOT 4
- Pluralization Issue HOT 2
- Consider switching to a regularly maintained sprintf package HOT 2
- how to handle simple formatting like bold or italic HOT 2
- Cannot use Link of 'react-router' as component HOT 5
- variables doesn't work HOT 2
- Issue when using interpolation with numbers HOT 2
- Name of the option to select a specific pluralization HOT 2
- Locales are inheritance HOT 1
- Translation of a text with a % character causes "SyntaxError: [sprintf] unexpected placeholder" HOT 4
- Fallback does not work with string '0' HOT 1
- split confusion HOT 1
- Why is translationnotfound fired only when fallback is provided? HOT 2
- Passing react dom element to a placeholder HOT 2
- Feature request: Multiple counts HOT 1
- onError callback not getting called when interpolation error occurs HOT 4
- Bad iteration if language fallback fails
- Add support for more plural forms HOT 2
- Missing translation:
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 counterpart.