MyBB Community Forums

Full Version: A simple but useful suggestion, I think
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,


While translating, it's a huge work to determine if a language variable is used by Javascript.
In French, we have a large use of single quotes in phrases.
If a variable is used by JS it's necessary escape the quotes even although they are in a variable in double quotes.

I suggest a simple trick : just use a prefix like 'js_' for these variables so the translators knows immediately if the single quotes should be escaped.

Another way is to produce the list of language variables, with the filenames where they are in.

What do you think about ? Smile
Up !  Huh 


Nobody ?


It's a hard work, did you know ?

I wrote a script to extract all JS calls, it results as a 10000+ lines file !!! With duplicates, for sure. But hardly usable! Toungue
Well - there is nothing simple about your suggestion^^

Adding a js_ prefix would require, that all translators update their translations for 1.8.1 --> big effort.
Furthermore each and every language string needs to be checked whether it's displayed using JS or not and this may change at any point in time... (same for creating a list).

Why don't you just escape every quote? You could easily do that using a script^^ find every ' and replace it by \' ;-)
I see a few problems:

1. Like Nik101010 said, changing the keys to the translation tables would require all translators update their translations for a bug fix version.

2. The list of phrases with an apostrophe (or other character which must be escaped in JavaScript) varies by language. Should a key be prefixed with js_ because the French C'est la vie includes an apostrophe even though in English (that's life) doesn't?

3. Why go through the list of language keys looking for a js_ prefix when you could just look for apostrophes in the values?
OK...

If I escape all the quotes in each language file, it will never produce an incorrect display?

Are you sure that PHP will remove all escape characters?
Is the script using stripslashes() in all cases?
Hi,


After MyBB code analysis, I'm almost sure that the language variables are directly read from the file and added to the $lang array without any other manipulation. The stripslashes() function is never used.
So your suggestion of escaping every quote is a bad idea and could produce bad displays.

And now, what's your proposal?
I'll try using HTML entities for all accented chars as well for quotes, encoding the lang files in ANSI rather than UTF8.

Hoping an answer...

Regards
Hi,

sorry no idea left... I was pretty sure php would treat \ as escape character, but doesn't seem to be like that... Currently a list would probably be the only solution...
Use of entities it's impossible because entities does not work with JS!

There only remains taking off the list of variables used by JS!

Can a developer build this list please ? Wink