[cmake-developers] [DISCUSSION] CMake Localization (L10N)

Alex Turbov i.zaufi at gmail.com
Wed Apr 19 14:44:34 EDT 2017


absolutely agreed.


On Wed, Apr 19, 2017 at 1:52 PM, Domen Vrankar <domen.vrankar at gmail.com>
wrote:

> 2017-04-18 19:16 GMT+02:00 Konstantin Podsvirov <konstantin at podsvirov.pro>
> :
>
>> Draft code:
>>
>> > set(GREETING "greeting message" # Optional default value
>> >  en "Hello, world!"
>> >  ru "Привет, мир!")
>> >
>> > set(CMAKE_OUTPUT_LOCALE "en") # Or CMAKE_L10N_LOCALE...
>> >
>> > message("$L10N{GREETING}") # Hello, world!
>> >
>> > set(CMAKE_OUTPUT_LOCALE "fr")
>> >
>> > message("$L10N{GREETING}") # greeting text
>> >
>> > message("$L10N:ru{GREETING}") # Привет, мир!
>>
>> Any feedback?
>
>
> 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.
>
> 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.
>
> That being said I'd suggest a more generic alternative that can be used
> for things other than localization:
>
> Access by array position:
> > set(GREETING "greeting message" "Hello, world!" "Привет, мир!")
> > message(${GREETING}) # prints "greeting message"
> > message(${GREETING:0}) # also prints "greeting message"
> > message(${GREETING:1}) # prints "Hello, world!"
> > message(${GREETING:2}) # prints "Привет, мир!"
> where the underlying structure of GREETING is "greeting message;Hello,
> world!;Привет, мир!"
>
> Or taking that even further by defining maps:
> > set(GREETING "greeting message" "en:Hello, world!" "ru:Привет, мир!")
> > message(${GREETING}) # prints "greeting message"
> > message(${GREETING:}) # also prints "greeting message"
> > message(${GREETING:en}) # prints "Hello, world!"
> > message(${GREETING:ru}) # prints "Привет, мир!"
> where the underlying structure of GREETING is "greeting message;en:Hello,
> world!;ru:Привет, мир!"
>
> This could then be used for e.g. for creating enums e.g.:
> > set(BUILD_TYPE_OPTIONS "default_flags" "Debug:debug_flags"
> "Release:release_flags" ...)
> > message("using flags:  ${CMAKE_BUILD_TYPE_OPTIONS:${CMAKE_BUILD_TYPE}}")
> # error if outside of range (e.g. OddRelease was specified for
> CMAKE_BUILD_TYPE)
>
> For this to really be useful support for if() command would also be
> required.
>
> Regards,
> Domen
>
>
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more
> information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at http://www.kitware.com/
> opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake-developers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20170420/d2853c24/attachment.html>


More information about the cmake-developers mailing list