• 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

Pepelac

Well-known member
#1
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/
Andrew.
 

Attachments

Pepelac

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

Attachments

Pepelac

Well-known member
#5
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.

:eek:
 

Pepelac

Well-known member
#6
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
PHP:
$caches = $languageModel->importLanguageXml($document, $input['overwrite_language_id'], $input['parent_language_id']);
should be (based on importLanguageXml method definition from XenForo_Model_Language class)
PHP:
$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"
 

Pepelac

Well-known member
#9
so i'm back :)

class XenForo_Model_Language, lines 347-379
there is duplicated method call $this->resetLocalCacheData('allLanguages'); in function rebuildLanguageCache
PHP:
/**
	 * 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()
	{
		$this->resetLocalCacheData('allLanguages');

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

		return $languages;
	}

	/**
	 * Rebuilds the full language cache.
	 *
	 * @return array Format: [language id] => info, with phrase cache as array
	 */
	public function rebuildLanguageCache()
	{
		$this->resetLocalCacheData('allLanguages');

		$languages = $this->getAllLanguagesForCache();

		$this->_getDataRegistryModel()->set('languages', $languages);

		return $languages;
	}
and after all, i've added one line of the code into class XenForo_Model_Phrase after line 970.
PHP:
$this->compileAllPhrasesInLanguage($languageId);
and i've got my language imported successfully on my local machine...

hope that all this stuff will be fixed asap.
 

Lucas

Well-known member
#10
so i'm back :)

file XenForo_Model_Language, lines 347-379
there is duplicated method call $this->resetLocalCacheData('allLanguages'); in function rebuildLanguageCache
PHP:
/**
	 * 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()
	{
		$this->resetLocalCacheData('allLanguages');

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

		return $languages;
	}

	/**
	 * Rebuilds the full language cache.
	 *
	 * @return array Format: [language id] => info, with phrase cache as array
	 */
	public function rebuildLanguageCache()
	{
		$this->resetLocalCacheData('allLanguages');

		$languages = $this->getAllLanguagesForCache();

		$this->_getDataRegistryModel()->set('languages', $languages);

		return $languages;
	}
and after all, i've added one line of the code into file XenForo_Model_Phrase after line 970.
PHP:
$this->compileAllPhrasesInLanguage($languageId);
and i've got my language imported successfully on my local machine...

hope that all this stuff will be fixed asap.
What file is this in?
 

yoghurtfarmer

Well-known member
#12
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.
 

Lucas

Well-known member
#13
XenForo_Model_Language - library/XenForo/Model/Language.php
XenForo_Model_Phrase - library/XenForo/Model/Phrase.php
Hey,

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

Thanks btw!
 

Puntocom

Well-known member
#14
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.
 
#20
sorry

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

Is it enough?

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