1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Fixed Bug? Importing russian language - phrases won't compile

Discussion in 'Resolved Bug Reports' started by Pepelac, Oct 6, 2010.

  1. Pepelac

    Pepelac Well-Known Member

    Hi, is it my problem, or is it a bug?

    I've got a xml file, based on exported language file from admin panel. See sample of this file in attachment.

    The problem is - after import i can see phrases in admin panel. Changed phrases are shown red (is it good?). But when i'm switching language from english to russian - there are no any of translated phrase on my pages.

    So i've looked into my database.
    There are 3 tables with prefix xf_phrases. And after import, table "xf_phrase_compiled" has no any data in russian. So there are no any word in russian on pages.

    If I change phrase after import and save it - it appears be in the table "xf_phrase_compiled".

    What i've done to get it work on the forum:
    - made a script, which reads all phrases from table "xf_phrase" based on language id from admin panel and inserts all the data into table "xf_phrase_compiled".
    - after that I need to rebuild templates cache, which can be done only by adding/deleting other language (is there other way to rebuild templates cache???).

    Any help would be appreciated. Link to forum - http://www.xf-russia.ru/forum/

    Attached Files:

  2. Pepelac

    Pepelac Well-Known Member

    and one more thing.
    if i'm overwriting existing russian language by importing it - it creates child language instead of overwriting. see screenshot

    Attached Files:

  3. Vladislav Rastrusny

    Vladislav Rastrusny Active Member

    Does that happen only with russian language? Or with any other language as well?
  4. Pepelac

    Pepelac Well-Known Member

    with all languages. i've tried english and got the same child language
  5. Pepelac

    Pepelac Well-Known Member

    same situation on my local machine on clean install.
    first of all - error while installation like in this post - http://xenforo.com/community/threads/beta-server-error-while-install.4868/. couple of refreshes and i've got it installed.
    then - export default (and only one existing language in admin panel) english language (empty btw, only tag with language definitions) and import it back to system with overwriting existing language. again same error - "An error occurred. Please click the button below for more information." and then - tada here we are - child english language - http://img.skitch.com/20101006-pcp5d94y1fr4dd4bp8ik3hkq4h.jpg

    and nice autoincrement values in db (after clean install):
    - xf_phrase - 11439
    - xf_phrase_map - 25762
    - and about 8,655 records in the xf_phrase_compile table.

    Romchik® likes this.
  6. Pepelac

    Pepelac Well-Known Member

    nice ;)
    so i'll post here some errors in php which i'll find.
    here we are, first error:
    file /library/XenForo/ControllerAdmin/Language.php, line 260
    $caches $languageModel->importLanguageXml($document$input['overwrite_language_id'], $input['parent_language_id']);
    should be (based on importLanguageXml method definition from XenForo_Model_Language class)
    $caches $languageModel->importLanguageXml($document$input['parent_language_id'], $input['overwrite_language_id']);
    PS. I've changed that line in php on my local machine, and default english xml file was imported flawlessly, but when i've tried my russian translate (288KB xml file, about 1500 phrases) script died with error "Fatal error: Maximum execution time of 30 seconds exceeded in bla-bla-bla"
  7. Pepelac

    Pepelac Well-Known Member

  8. Pepelac

    Pepelac Well-Known Member

  9. Pepelac

    Pepelac Well-Known Member

    so i'm back :)

    class XenForo_Model_Language, lines 347-379
    there is duplicated method call $this->resetLocalCacheData('allLanguages'); in function rebuildLanguageCache
         * Gets all languages in the format expected by the language cache.
         * @return array Format: [language id] => info, with phrase cache as array
    public function getAllLanguagesForCache()

    $languages $this->getAllLanguages();
            foreach (
    $languages AS &$language)
    $language['phrase_cache'] = unserialize($language['phrase_cache']);


         * Rebuilds the full language cache.
         * @return array Format: [language id] => info, with phrase cache as array
    public function rebuildLanguageCache()

    $languages $this->getAllLanguagesForCache();


    and after all, i've added one line of the code into class XenForo_Model_Phrase after line 970.
    and i've got my language imported successfully on my local machine...

    hope that all this stuff will be fixed asap.
    Rob Fritz, Perspektif, krstep and 3 others like this.
  10. Lucas

    Lucas Well-Known Member

    What file is this in?
  11. Pepelac

    Pepelac Well-Known Member

    XenForo_Model_Language - library/XenForo/Model/Language.php
    XenForo_Model_Phrase - library/XenForo/Model/Phrase.php
  12. yoghurtfarmer

    yoghurtfarmer Well-Known Member

    I can confirm this happens with any imported language, some with only 2 phrases.

    The phrases are highlighted in red, and once you click on them and resubmit it. They appear correctly, otherwise they don't show up.
  13. Lucas

    Lucas Well-Known Member


    All I had to fix this was add this line: $this->compileAllPhrasesInLanguage($languageId);
    where you stated. The other stuff was unnecessary.

    Thanks btw!
  14. Puntocom

    Puntocom Well-Known Member

    Sorry but it's not clear for me how to make this modification. Please can you specify the code block before and after? I'm working in XFHispano.org and I can't use the work done for another sites.

    Kind regards.
  15. Puntocom

    Puntocom Well-Known Member

    Solved, thanks Lucas :)

    Just put $this->compileAllPhrasesInLanguage($languageId); after the line 970 in library/XenForo/Model/Phrase.php
    Rob Fritz likes this.
  16. Mike

    Mike XenForo Developer Staff Member

    This is fixed now. The approach has been altered a fair bit, and should hopefully be more resilient against timeouts as well.
    Cool, Rob Fritz, Ahmed and 1 other person like this.
  17. Pepelac

    Pepelac Well-Known Member

    Thanks, glad to hear that :)
  18. soloarquitectura

    soloarquitectura Well-Known Member

    Great news. Thanks Mike :)
  19. Perspektif

    Perspektif Active Member


    Language.php files and Phrase.php
    where to add? i which I add the line?
  20. Perspektif

    Perspektif Active Member


    after the line 970 in library/XenForo/Model/Phrase.php

    Is it enough?

    edit two: no. is not it enough...
    installed but not activated

Share This Page