qbcore-framework / qb-core

FiveM RP Framework Core :muscle:
GNU General Public License v3.0
590 stars 960 forks source link

Fix subs not getting replaced in locales #967

Closed r3ps4J closed 1 year ago

r3ps4J commented 1 year ago

Description

This pull request fixes subs not getting replaced in locale strings. While working with locale strings I found that subs were not getting replaced, after some testing it appears that there is a double % in the template that should not be there. After removing 1 % the subs were getting replaced again. They would also get replaced with no % at all, that being an escape character it's probably best the escape stays in.

Checklist

r3ps4J commented 1 year ago

Apart from this, I'd like to suggest a change for the same piece of code. I think it is a good idea to switch out variables with {variable} to {{variable}}, this way it uses the same interpolation basics as i18next which is a commonly used libarary for i18n in NUI. This way language files can be shared between NUI and the other parts of the script. Seeing as subs have never worked, this would not result in backwards compatibility issues. For reference see https://www.i18next.com/translation-function/interpolation