How to add the % symbol to a string?
josefnpat opened this issue · 4 comments
josefnpat commented
Is there a way to have a string with a % symbol in it?
I think the library thinks it's a variable, and tries to format it. I've tried \% and %%.
kikito commented
Can you provide an example code showing the issue?
josefnpat commented
No problem!;
nothanks@DESKTOP-P3PO2HO ~/repos/i18n.lua
$ cat fail.lua
i18n = require'i18n.init'
i18n.set('en.test','%{name} feels 100%!')
print(i18n('test',{
name = "Seppi",
}))
nothanks@DESKTOP-P3PO2HO ~/repos/i18n.lua
$ lua fail.lua
lua: ./i18n/interpolate.lua:32: bad argument #2 to 'format' (no value)
stack traceback:
[C]: in function 'format'
./i18n/interpolate.lua:32: in function <./i18n/interpolate.lua:27>
(tail call): ?
(tail call): ?
./i18n/init.lua:140: in function <./i18n/init.lua:132>
(tail call): ?
fail.lua:5: in main chunk
[C]: ?
nothanks@DESKTOP-P3PO2HO ~/repos/i18n.lua
$ cat good.lua
i18n = require'i18n.init'
i18n.set('en.test','%{name} feels 100 percent!')
print(i18n('test',{
name = "Seppi",
}))
nothanks@DESKTOP-P3PO2HO ~/repos/i18n.lua
$ lua good.lua
Seppi feels 100 percent!
kikito commented
Hi, I have updated a change that should fix the issue. Thanks for reporting it!
josefnpat commented
Awesome! You rock; i'll be updating my internal repos asap!