You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, first at all, this is a great & simpler package, it's very useful.
I'm thinking about the use of second/plural argument in __n function. Making some checks and viewing your tests and implementation, the second argument seems to be meaningless except for keeping it in a file if it doesn't exist. For example:
it('allows an alternative locale to be set',function(){var__n=y18n({locale: 'pirate',directory: path.join(__dirname,'locales')}).__n__n('%d cat','%d cats',1).should.equal('1 land catfish')__n('%d cat','%d cats',3).should.equal('3 land catfishes')})
Here I can write __n('%d cat', 'foo bar', 3) and still get 3 land catfishes.
unknown
Perhaps it might be more useful (sometimes at least) to have another method y18n.__p(key, number, ...args) to use without worrying about updateFiles feature or maybe with a default "unknown" value.
I don't know... It's just a practical suggestion.
The text was updated successfully, but these errors were encountered:
The current behavior only updates the cache and the language file if the singular is not found and updateFiles is true.
In your example __n('%d cat', 'foo bar', 3) only the plural was updated, which is why you still get 3 land catfishes.
So this might be a few different enhancements:
Update cache/language file if a new plural string is observed
Ability to update the cache w/o updating the language file, which would use the strings for the current instance of y18n.
A way to prefer the provided strings over the current cache such as new method or option to current method, which would use the provided strings for just that single call.
Set default of plural arg if there is a matching singular/quantity in the cache so that pluralString could be optional.
@leandrojdl did I interpret your suggestion correctly?
Im sorry for the delay. It has happened a lot due the Covid and because of other organisations deprecating on purposes to delay my work and fooling around with the Atom program.
Hi, first at all, this is a great & simpler package, it's very useful.
I'm thinking about the use of second/plural argument in
__n
function. Making some checks and viewing your tests and implementation, the second argument seems to be meaningless except for keeping it in a file if it doesn't exist. For example:Here I can write
__n('%d cat', 'foo bar', 3)
and still get3 land catfishes
.unknown
Perhaps it might be more useful (sometimes at least) to have another method
y18n.__p(key, number, ...args)
to use without worrying about updateFiles feature or maybe with a default "unknown" value.I don't know... It's just a practical suggestion.
The text was updated successfully, but these errors were encountered: