<div dir="ltr">2017-04-18 19:16 GMT+02:00 Konstantin Podsvirov <span dir="ltr"><<a href="mailto:konstantin@podsvirov.pro" target="_blank">konstantin@podsvirov.pro</a>></span>:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Draft code:<br>
<br>
> set(GREETING "greeting message" # Optional default value<br>
>  en "Hello, world!"<br>
>  ru "Привет, мир!")<br>
><br>
> set(CMAKE_OUTPUT_LOCALE "en") # Or CMAKE_L10N_LOCALE...<br>
><br>
> message("$L10N{GREETING}") # Hello, world!<br>
><br>
> set(CMAKE_OUTPUT_LOCALE "fr")<br>
><br>
> message("$L10N{GREETING}") # greeting text<br>
><br>
> message("$L10N:ru{GREETING}") # Привет, мир!<br>
<br>
Any feedback?</blockquote><div><br></div><div>Coming from a small country I'm not too keen on localization as it makes my life harder - in case of an error I have to guess what the english version of the error message would look like just to get results on Google.<br><br></div></div>I somewhat understand the wish of non programmers to see text in their own language but for developers english is de facto programming standard language so I don't see a reason for such an addition.<br><br></div><div class="gmail_extra">That being said I'd suggest a more generic alternative that can be used for things other than localization:<br><br></div><div class="gmail_extra">Access by array position:<br></div><div class="gmail_extra">> set(GREETING "greeting message" "Hello, world!" "Привет, мир!")<br></div><div class="gmail_extra">> message(${GREETING}) # prints "greeting message"<br>> message(${GREETING:0}) # also prints "greeting message"<br>> message(${GREETING:1}) # prints "Hello, world!"<br>> message(${GREETING:2}) # prints "Привет, мир!"</div><div class="gmail_extra">where the underlying structure of GREETING is "greeting message;Hello, world!;Привет, мир!"<br></div><div class="gmail_extra"><br></div><div class="gmail_extra">Or taking that even further by defining maps:<br><div class="gmail_extra">> set(GREETING "greeting message" "en:Hello, world!" "ru:Привет, мир!")<br></div>> message(${GREETING}) # prints "greeting message"<br>> message(${GREETING:}) # also prints "greeting message"<br>> message(${GREETING:en}) # prints "Hello, world!"<br>> message(${GREETING:ru}) # prints "Привет, мир!"<br></div><div class="gmail_extra">where the underlying structure of GREETING is "greeting message;en:Hello, world!;ru:Привет, мир!"<br><br></div><div class="gmail_extra">This could then be used for e.g. for creating enums e.g.:<br></div><div class="gmail_extra">> set(BUILD_TYPE_OPTIONS "default_flags" "Debug:debug_flags" "Release:release_flags" ...)<br></div><div class="gmail_extra">> message("using flags:  ${CMAKE_BUILD_TYPE_OPTIONS:${CMAKE_BUILD_TYPE}}") # error if outside of range (e.g. OddRelease was specified for CMAKE_BUILD_TYPE)<br></div><div class="gmail_extra"><br>For this to really be useful support for if() command would also be required.<br></div><div class="gmail_extra"><br></div><div class="gmail_extra">Regards,<br></div><div class="gmail_extra">Domen<br></div><div class="gmail_extra"><br></div></div>