How to get a localized string describing a Keysym?
===

I'm looking for a function that would return a string containing an accurate, user friendly and localized information about the provided Keysym. This is a feature is used for example in most GUIs to display accelerator's value (i.e. "Copy (Ctrl. C)"). For example :

    char* name = convert(XK_Return);
    // If locale is en_US : name == "Return"
    // If locale is fr_FR : name == "Entrée"
    // ...

I know of the following functions :

- XKeysymToString : The returned string is neither localized nor beautiful, since the return value is simply the macro identifier with the "XK_" removed... Hence you have XK_Return -> "Return" (great), XK_space -> "space" (not capitalized), XK_braketleft -> "braketleft" (no space between words, not capitalized), XK_dead_grave -> "dead_grave" (underscore as space, not capitalized)...

- XkbTranslateKeySym : Doesn't work for modifiers or dead keys, i.e. XK_F5 or XK_Shift_L.

- GetKeyNameText (Windows only) : For reference : works like a charm, the output string is localized and fits quite well with whatever is hard printed on the keyboard.

After several hours of research, I found out that for example LibreOffice is using a custom localization table to correct the output of XKeysymToString (see [this bug report][1]). SDL 2.0 and Allegro 5 both use a static table with English key names. OIS simply uses the raw output of XKeysymToString.

What is the good way to handle this situation ?


  [1]: http://lists.freedesktop.org/archives/libreoffice/2012-June/032883.html