i18n, t helper array localized tokens fail
for example <%= t(['user.welcome', user.name]) %> is fine but
var tokens = ['user', 'test']; <%= t(['user.welcome', tokens ]) %> is fail
T(global) method in i18n.js function translate(path, locale, defaultValue) { ... substitute = path; path = substitute.shift();
// i think need to add this code
// substitute = substitute.shift()
}
It should not work in both cases. Correct usage:
t('user.welcome');
or
t('user.welcome', 'Default welcome message');
sorry .. my english skill is poor but there is no problem just read i mean,
example language resource upload: "Uploaded at % by %"
i try helper t( [ 'upload', ['time', 'user' ]) then output is Uploaded at time, use by %
because
substitute = path; substitute = [ 'upload', ['time', 'user' ] ] path = substitute.shift(); substitute = [ ['time', 'user' ] ]
substitute.forEach(function(substitution) {
..
// output is " Uploaded at time, use by %"
// i think need to add this code
substitute = substitute.shift(); then substitute = ['time', 'user' ]
}
Yep, i see what you mean now, thanks for explanation, i just forgot about this feature. Yes, first argument could be array of [pattern, substitution1, ..., substN]. Not [pattern, [s1, s2, s3]] - this is why you have a problem. I believe no code changes required.
On Wed, Feb 13, 2013 at 4:30 PM, Sung Yeol Yim [email protected]:
sorry .. my english skill is poor but there is no problem just read i mean,
example language resource upload: "Uploaded at % by %"
i try helper t( [ 'upload', ['time', 'user' ]) then output is Uploaded at time, use by %
because
substitute = path; substitute = [ 'upload', ['time', 'user' ] ] path = substitute.shift(); substitute = [ ['time', 'user' ] ]
substitute.forEach(function(substitution) { .. // output is " Uploaded at time, use by %"
// i think need to add this code substitute = substitute.shift(); then substitute = ['time', 'user' ] }
— Reply to this email directly or view it on GitHubhttps://github.com/1602/compound/issues/391#issuecomment-13478950.
thanks,i understand now
i just want use array type arguments .
so i use this.. <%- t(['user.welcome'].concat( someArray)] ) %>