The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

cP not showing miss lang key class since 11.25 STABLE

Discussion in 'General Discussion' started by Gino Viroli, Feb 19, 2010.

  1. Gino Viroli

    Gino Viroli Active Member

    Joined:
    Oct 2, 2007
    Messages:
    40
    Likes Received:
    0
    Trophy Points:
    6
    Before 11.25 when I set for cPanel a language file that is not the standard english.dat file, let's say italian.dat, cP used to show all missing language keys by showing a red dotted box around each text displaied in its interface for which the language key was missing on the italian.dat file.

    This was useful to find the name of the missing language keys and to add them in the italian.dat file. Infact lokking in the code of the displaied red boxes you could find a comment written by cp saying "missing lang key NAME_OF_THE_LANG_KEY".


    Since 11.25 cP does not show this missing languages key anymore. So?
    What do we do? Don't you want us to translate it anymore??? :)
     
  2. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Friendly Moderator Note

    I am not sure how this is relevant to APIs and plugins, so I have moved this thread into general cPanel/WHM discussion.
     
  3. cPDan

    cPDan cPanel Staff
    Staff Member

    Joined:
    Mar 9, 2004
    Messages:
    711
    Likes Received:
    4
    Trophy Points:
    18
    Hello,

    This behavior has changed with Cpanel::Locale. Here is how and why:

    The legacy system used this format:

    english: ArbitraryKey: Hello World
    french: ArbitraryKey: Bonjour Monde

    And if it couldn't find 'ArbitraryKey' it had to die because it had no way to know what to say.

    In Cpanel::Locale the "ArbitraryKey" is gone. Now the key *is* the phrase.

    en: Hello World:
    fr: Hello World: Bonjour Monde

    If 'Hello World' is not found in the locale and it is not found in the default 'en' then the phrase itself is rendered.

    In other words there is no need to report/die if a phrase is given that we don't know about because it can gracefully fall back to itself since it is what you wanted to say.

    You can add
    LOCALE_LOG_MISSING=1
    to a specific user's cPanel user's file and you'll get a detailed log message about each phrase that was not found and subsequently used directly for pages that user hits.

    If you do custom things then you should start using the new format so that missing keys render as 'Hello World' instead of 'ArbitraryKey'.

    Have a look at WebHome < CpanelLocale < TWiki for more information.
     
  4. cPDan

    cPDan cPanel Staff
    Staff Member

    Joined:
    Mar 9, 2004
    Messages:
    711
    Likes Received:
    4
    Trophy Points:
    18
    Side note:

    Aside from documenting LOCALE_LOG_MISSING=1 I also need to get the case for documenting the cpanel tag and API2 usage done.

    For now here is a quick guide:

    Note '...' referse to the maktext format phrase, including possible bracket notation arguments)

    <cpanel Locale="maketext(...)">
    or even easier:
    <cptext '...'>

    An API2 example is this:

    Hard coded:
    [p]Hello World[/p]
    Cpanel::Locale:
    [p]maketext('Hello World')[/p]

    I'll make sure that the more complete documentation will be up at the URL above in the next few days.
     
  5. Gino Viroli

    Gino Viroli Active Member

    Joined:
    Oct 2, 2007
    Messages:
    40
    Likes Received:
    0
    Trophy Points:
    6

    It makes sense not to show all red boxes, but plz help explain how this LOCALE_LOG_MISSING=1 works.

    Where do I trun it on, I'm a resseler I have no root access to the server.

    Exactly in which file do I need to write the string "LOCALE_LOG_MISSING=1" ???
     
  6. Trueliar

    Trueliar Registered

    Joined:
    May 30, 2010
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    are you so kind to share the translated file or cooperate to translate it?
     
  7. dexus

    dexus Well-Known Member

    Joined:
    Jan 14, 2006
    Messages:
    169
    Likes Received:
    0
    Trophy Points:
    16
    cPanel Access Level:
    Root Administrator
    I have to correct you on this... We actually need to know what is missing to be able to translate it... :)

    I don't understand how to translate missing phrases now?
     
  8. cPDan

    cPDan cPanel Staff
    Staff Member

    Joined:
    Mar 9, 2004
    Messages:
    711
    Likes Received:
    4
    Trophy Points:
    18
    Sorry, what I meant was there is no reason to have a big scary red box that the end user can't do anything about since we can fall back to the phrase itself and log the issue if desired.

    1) manually editing files and recompiling the database (ick)
    or
    2) Main -> Locales -> Edit a Locale ->Locale Editor - Bulk Mode
     
  9. cPDan

    cPDan cPanel Staff
    Staff Member

    Joined:
    Mar 9, 2004
    Messages:
    711
    Likes Received:
    4
    Trophy Points:
    18
    It goes in "a specific user's cPanel user's file" which is /var/cpanel/users/USERNAME, only root can write to those files and there isn't currently a UI to toggle it. (perhaps a useful feature?)
     
  10. dexus

    dexus Well-Known Member

    Joined:
    Jan 14, 2006
    Messages:
    169
    Likes Received:
    0
    Trophy Points:
    16
    cPanel Access Level:
    Root Administrator
    Ok, I understand that part, but we have an older translation that doesn't contain all phrases available in latest cPanel version. How can we know exactly which phrases are missing to be able to translate them now?

    Before this new locales/translation method, WHM was showing all phrases an you could find the ones that are not translated, and now I don't see a logical way to get a missing phrases that should be translated...
     
  11. cPDan

    cPDan cPanel Staff
    Staff Member

    Joined:
    Mar 9, 2004
    Messages:
    711
    Likes Received:
    4
    Trophy Points:
    18
    I see, my apologies for mis-understanding :)

    That is actually easier than scanning a UI or a log for errors about missing keys.

    Simply compare the keys in /var/cpanel/locale/en.gdbm to the keys of the corresponding GDBM for the locale in question.

    I'll work up a small example of what I mean and attach it here in a few minutes.
     
  12. cPDan

    cPDan cPanel Staff
    Staff Member

    Joined:
    Mar 9, 2004
    Messages:
    711
    Likes Received:
    4
    Trophy Points:
    18
    script is in dev review ATM ...
     
  13. cPDan

    cPDan cPanel Staff
    Staff Member

    Joined:
    Mar 9, 2004
    Messages:
    711
    Likes Received:
    4
    Trophy Points:
    18
    The attached .txt file (extension added for forum software ...) will be /scripts/comparegdbm in coming builds.

    execute it without arguments to get a usage message.

    HTH!
     

    Attached Files:

  14. dexus

    dexus Well-Known Member

    Joined:
    Jan 14, 2006
    Messages:
    169
    Likes Received:
    0
    Trophy Points:
    16
    cPanel Access Level:
    Root Administrator
    Thanks. :)

    There is just one problem with this, you would still need to go through langauge XML file and search one by one key and copy it one by one to another language file, so I made one small modification so it can print the output already formated as XML language file... :)

    Code:
    29c29
    <             print "$ARGV[1] is missing \"$k\"\n";
    ---
    >             print "<item key=\"$k\">$GDBM_FILE_A{$k}</item>\n";
    
    ...so you can just save script output to a file, translate all values, and then after translation just add all lines to appropriate location in language XML file and import it again from WHM.
     
  15. cPDan

    cPDan cPanel Staff
    Staff Member

    Joined:
    Mar 9, 2004
    Messages:
    711
    Likes Received:
    4
    Trophy Points:
    18
    The XML format and import would work but would be overly complicated.

    You could just turn it into YAML and append that to the .local file, done :)

    In fact I'd thought about adding a --yaml flag ...
     
  16. cPDan

    cPDan cPanel Staff
    Staff Member

    Joined:
    Mar 9, 2004
    Messages:
    711
    Likes Received:
    4
    Trophy Points:
    18
    Plus depending on the key you will end up with broken XML
     
  17. dexus

    dexus Well-Known Member

    Joined:
    Jan 14, 2006
    Messages:
    169
    Likes Received:
    0
    Trophy Points:
    16
    cPanel Access Level:
    Root Administrator
    Well, it is important to be carefull with my method and to know where exactly the keys should go in XML file, and file B would have to be the older file that have some keys missing...

    Where is that .local file? Can you please explain this method a little bit?

    Thanks.
     
  18. cPDan

    cPDan cPanel Staff
    Staff Member

    Joined:
    Mar 9, 2004
    Messages:
    711
    Likes Received:
    4
    Trophy Points:
    18
    Yes, the “Introduction” section at WebHome < CpanelLocale < TWiki describes the files involved and some key principles.

    Let me know if you have any questions that those documents do not address.

    Thanks!
     
  19. dexus

    dexus Well-Known Member

    Joined:
    Jan 14, 2006
    Messages:
    169
    Likes Received:
    0
    Trophy Points:
    16
    cPanel Access Level:
    Root Administrator
    Thanks, but I am now totaly confused... I read that introduction and at first I thought I figured it out, but then I went to the server and realised that all those directories mentined there are empty...??

    Root-specific files:

    * /usr/local/cpanel/locale/en.yaml — The base file
    * /var/cpanel/locale.local/en.yaml — The local file

    Theme-specific files:

    * /usr/local/cpanel/base/frontend/x3/locale/en.yaml — The base file
    * /usr/local/cpanel/base/frontend/x3/locale/en.yaml.local — The local file

    Actually only directory "/usr/local/cpanel/locale/" have some files in it, but they are mostly empty files, only en.yaml have 30 rows... ??

    So I am totaly lost now, where should I "append" translated phrases as yaml when there are no files in x3 theme folder that I would like to add some missing translations to a locale...?

    What would be the exact procedure to add those phrases in yaml file?

    Thank you.
     
  20. cPDan

    cPDan cPanel Staff
    Staff Member

    Joined:
    Mar 9, 2004
    Messages:
    711
    Likes Received:
    4
    Trophy Points:
    18
    Correct, by default there are no local edits so there are no files. Those paths are just where the compiler looks.

    Those are the core files, en's values are supposed to be empty, the others are in the process of being updated. You'd never want to edit those as your edits will be wiped out. Always edit the "local" files.

    You can manually edit a YAML file (they are human readable) or use a tool to build the YAML out of a data structure.

    What locale are you wanting to add new phrases to?
     
Loading...

Share This Page