ElkArte Community

Elk Development => Feature Discussion => Topic started by: Joshua Dickerson on July 13, 2015, 05:55:07 pm

Title: Translate this
Post by: Joshua Dickerson on July 13, 2015, 05:55:07 pm
I was trying to think of how to make it so that you can navigate around a forum and make strings translatable or at least view what the key of the language string is. Thinking of an easy way to do that I decided that I could just wrap the string in a span with a class "string" (or something) and then a data-lang-key="[lang key]". The result would be something like <span class="lang_string" data-lang-key="board_name">Board name</span>. Then all of the $txt uses would be changed to txt('key'). Using some JS, you could click (or right click) and then it would take you to the language editor and let you change the language strings.

Code: [Select]
function ($key, $do_wrapper = false)
{
    global $txt;

    return !$do_wrapper ? $txt[$key] : '<span class="lang_string" data-lang-key="' . $key . '">' . $txt[$key] . '</span>';
}

Anywhere this wouldn't work?
Title: Re: Translate this
Post by: Spuds on July 14, 2015, 07:53:00 am
Cool idea ...
QuoteAnywhere this wouldn't work?
no major things come to mind, I'm sure that there could be a couple of odd spots where the key is built (extra logic), but thats no reason to not do this.
Title: Re: Translate this
Post by: emanuele on July 14, 2015, 08:06:59 am
Interesting! :D
Title: Re: Translate this
Post by: [SiNaN] on July 14, 2015, 12:52:15 pm
Had a similar idea after I coded my language editor. Coincidentally, recently got around to trying a very rough mock-up with a project I'm working on. There are limitations such as when text strings only appear on conditions and when they are inside stuff where you can't have the necessary HTML like submit button values, select box options, page titles and similar stuff. Still it's a pleasant experience for a translator when they see the context of the stuff that they are translating. If you would like to have a taste of it, it's here: bluedream.info/demo/misao Don't worry about breaking it and play with it to your heart's content!
Title: Re: Translate this
Post by: emanuele on July 14, 2015, 02:56:45 pm
Awesome [SiNaN] ! :D