i18n-node
i18n-node copied to clipboard
Allow escaping or configuring ':' sepearator for object notation defaults
The documentation suggests using __l for generating express routes, however it's incompatible with objectNotation
, as :
separators are used for providing defaults
Given the following routes with objectNotation
on, they save the translation to JSON:
{
"/products/": "productID"
}
which in turn returns productID
from each
__('/products/:productID')
__('/products/:productID/somePage')
__('/products/:productID/somePage/:another')
It would be helpful to be able to escape the :
char, or configure which symbol to use (like object notation allows changing of .
)
Currently I'm working around it by wrapping __l
to replace :
with another char, and then replacing the substitute character after res.__l
is called, but this means my translation files don't match express routing conventions
Having this issue also – a 3rd party library is using __()
with strings containing :
, with updateFiles on this leads to really strange entries in the locale files.
Making it configurable is one approach – would it be simpler to escape colons with \
, so that \:
does not get interpreted as a default? Or perhaps like CSV does, treating ""
as an escapes "
, we could do ::
is interpreted as a single :
. I prefer the \
approach; I'd be happy to submit a PR :)
Do any maintainers have an opinion on this?
Uhhh, really kind of dreadful that colon cannot be escaped. I'm not a maintainer, but I think putting ::
to escape a colon is good. Might have to add an option to specify that ::
escapes :
to avoid possibly breaking someone.
I will say that the whole colon issue only comes into play if you have objectNotation
set to true
, which I am thinking of not doing, so that may make this not an issue for me.