Figure out how custom string translations can be included in install. I tried putting the languages/[lang-code] files in the config/install directory but they weren't picked up. When I check the user's language settings, they are set to English.

Comments

Kristen Pol’s picture

I tried another time with a new install profile with the same result. Unclear why it's not picking it up.

Kristen Pol’s picture

When I add the same config to a custom module, it does get installed ok.

Kristen Pol’s picture

I tried again with git_deploy enabled as part of the profile and it still didn't work.

Kristen Pol’s picture

I add the custom module to the install profile but then the translations were not loaded even though the module was enabled.

Kristen Pol’s picture

Ah... locale.module says this:

  // Skip running the translation imports if in the installer,
  // because it would break out of the installer flow. We have
  // built-in support for translation imports in the installer.

so I guess that makes sense it's not working for the last test case.

Kristen Pol’s picture

Ok... so for my next parlor trick, I ran through the install by choosing Spanish upon install instead of English. Then the installer barfs at the end with a fatal error and this is in the php log:

[23-Jul-2014 05:56:21 UTC] Uncaught PHP Exception Symfony\Component\Routing\Exception\ResourceNotFoundException: "None of the routers in the chain matched this request
GET / HTTP/1.1
Accept:          text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Charset:  ISO-8859-1,utf-8;q=0.7,*;q=0.7
Accept-Language: en-us,en;q=0.5
Host:            localhost
User-Agent:      Symfony/2.X

" at /Users/kristenpol/Sites/projects/drupal8/drupal-8.0-alpha13-foobar/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/ChainRouter.php line 202

My guess is that I built the config when English was the default language and when, I tried installing in Spanish, it got confused because it couldn't find English.

Kristen Pol’s picture

I guess I must have had some cruft in my old D8 core so I downloaded a new alpha13 and was able to install the custom install profile with German. But, the custom translations didn't get picked up.

Kristen Pol’s picture

As one final test for tonight, I installed custom install after choosing German and custom install had the custom module with the translation config in it. I didn't expect it to work for the new languages after the previous comment I found but just checking.

Upshot... I tried:

  • English - translations in install [custom-profile]/config/install/languages
  • English - translations in install [custom-profile]/modules/[custom-module]/config/install/languages
  • English (with git_deploy enabled)- translations in install [custom-profile]/modules/[custom-module]/config/install/languages
  • German - translations in install [custom-profile]/config/install/languages
  • German - translations in install [custom-profile]/modules/[custom-module]/config/install/languages

So... based on what I'm seeing, only the translations for the selected install language will be pulled over and I'm not sure how to pull over additional translations when language profile has these in them as well as how to get the additional custom translations pulled in from [somewhere]/config/install/languages/*.

Gábor Hojtsy’s picture

Yeah only overrides in the installed languages are imported. LanguageConfigOverrideImportTest shows that. LanguageConfigFactoryOverride will only create collections for the configured languages, see foreach (\Drupal::languageManager()->getLanguages() as $language) { in addCollections().

Although the install configs would only be considered in general when a module is installed, language has some code to take the overrides into account when a language is saved. See language_save() in language.module which invokes installLanguageOverrides() to take the language overrides for THAT language and install them as needed.

So theoretically as far as I see if/once you use language_save() to add a new language, their config overrides should be imported as well for all installed modules at that time. I don't think you committed any changes to the profile in git, I updated and did not see a change, so don't know what is your exact code.

Kristen Pol’s picture

Thanks! I'll take a look at language_save and I'll add the foobar install profile code to the testing area.

Kristen Pol’s picture

I have spent many hours on this and have made some progress in my local test install profile (not checked in yet). I have added some install tasks and can get the core translations to get sucked in for Spanish and French *if* I choose a language at the beginning of the installation process. If I choose English, then it doesn't do it so I'm missing some key code. I feel like I'm close but I'm too tired to keep banging my head against this tonight though.

Kristen Pol’s picture

I have added the code to the multilingual_demo install profile.

  • Choosing non-English language will get the Spanish and French core interface translations to be sucked in
  • Choosing English language will NOT get the Spanish and French core interface translations to be sucked in
  • Still not sucking in config translations (either in config/install/languages or modules/my_config/config/install/languages)
Kristen Pol’s picture

Title:Figure out how custom string translations can be included in install» Figure out how core interface translations and custom string (config) translations can be included in install
Gábor Hojtsy’s picture

Are you adding language (and locale) modules to the profile either way? Language module would suck in those translations IF the languages are configured as well. Picking French will enable language module (and locale) and add French. Which should result in the translations added.

Kristen Pol’s picture

"Are you adding language (and locale) modules to the profile either way?"

Yes, these are in the info yml file.

"Language module would suck in those translations IF the languages are configured as well. Picking French will enable language module (and locale) and add French. Which should result in the translations added."

The languages are configured and the languages show up.

I'm just getting back into this after vacation so trying to figure out where I left off and what is working and what isn't.

I did try adding git_deploy + core patch (locale-update-2030537-39.patch) + using latest core dev and then I get install profile error:

Notice: Undefined property: Drupal\Core\Extension\Extension::$uri in git_deploy_system_info_alter() (line 16 of profiles/multilingual_demo/modules/git_deploy/git_deploy.module).
git_deploy_system_info_alter(Array, Object, 'theme')
Drupal\Core\Extension\ModuleHandler->alter('system_info', Array, Object, 'theme')
Drupal\Core\Extension\ThemeHandler->rebuildThemeData()
Drupal\Core\Extension\ThemeHandler->refreshInfo()
Drupal\Core\Extension\ThemeHandler->listInfo()
list_themes()
_drupal_maintenance_theme()
drupal_maintenance_theme()
install_begin_request(Array)
install_drupal()

I don't get that error when using patch with alpha 13.

Note that all the code is checked in as the multilingual_demo in the repo.

Kristen Pol’s picture

Very strange. I am testing it again and choosing English and it is installing both Spanish & French now (it didn't before). Maybe because I installed the core patch in alpha13.

But, it's leaving the interface in French because that's the last translation I install in the profile. So... now I need to see how to get it back so the interface is in English when installing in English.

Gábor Hojtsy’s picture

Hum! That is interesting. If you use alpha13 with the core patch applicable at the time, it will indeed download translations. Not sure why it leaves you in French :D

Kristen Pol’s picture

My plan is to debug why it's leaving me in French today. Goal: be able to install in English or another language and have core translations sucked in for Spanish+French while keeping the interface in whatever language I chose in the installer. Once that happens then I'll probably switch gears to building out the site again so I have more config to suck in.

Kristen Pol’s picture

Strange thing is that the current langcode, default langcode, and user's preferrred langcode are all set to "en" yet the interface is in French:

multilingual_demo_final_site_setup current_langcode = en
multilingual_demo_final_site_setup default_langcode = en
multilingual_demo_final_site_setup user_langcode = en

I got these from:

$current_langcode = \Drupal::languageManager()->getCurrentLanguage()->id;
$default_langcode = \Drupal::languageManager()->getDefaultLanguage()->id;
$user = \Drupal::currentUser();
$user_langcode = $user->getPreferredLangcode();
Kristen Pol’s picture

Issue summary:View changes
StatusFileSize
new16.89 KB

Hmm... I see Spanish some places too. ?? When checking the user's lang preference, it is set to English:

Gábor Hojtsy’s picture

Oh, HA! That is this bug: #2240459: Applying default language fallback rules to interface translation has impressively bad results it should be fixed on HEAD at this point. Basically a page can be mixed language per string where translations are not available in the primary language due to that bug :D

Kristen Pol’s picture

Oh, good! :) Ok... then I think for now I'll move back to building out functionality on the site. I can move back to this one once the git_deploy is working for latest dev. Thanks!

Kristen Pol’s picture

StatusFileSize
new18.95 KB
new36.07 KB

So using the latest git_deploy and latest core (and moving past various [new] errors in the installer) then we have success here:

* Interface UI is in English (which is what I chose)
* Translations installed for French
* Translations installed for Spanish

I'm getting other issues but I don't think they have anything to do with the installer code. I got some errors when installing like:

An AJAX HTTP request terminated abnormally.
Debugging information follows.
Path: http://d8dev.local/core/install.php?langcode=en&profile=multilingual_demo&id=1&op=do_nojs&op=do
StatusText: error
ResponseText:
ReadyState: 0

and

Notice: Trying to get property of non-object in locale_translation_source_check_file() (line 173 of core/modules/locale/locale.translation.inc).
locale_translation_source_check_file(Object)
locale_translation_batch_status_check('drupal', 'es', Array, Array)
call_user_func_array('locale_translation_batch_status_check', Array)
locale_translation_worker(Array)
call_user_func_array('locale_translation_worker', Array)
Drupal\Core\Cron->processQueues()
Drupal\Core\Cron->run()
install_finished(Array)
install_run_task(Array, Array)
install_run_tasks(Array)
install_drupal()
Notice: Trying to get property of non-object in locale_translation_source_check_file() (line 174 of core/modules/locale/locale.translation.inc).
locale_translation_source_check_file(Object)
locale_translation_batch_status_check('drupal', 'es', Array, Array)
call_user_func_array('locale_translation_batch_status_check', Array)
locale_translation_worker(Array)
call_user_func_array('locale_translation_worker', Array)
Drupal\Core\Cron->processQueues()
Drupal\Core\Cron->run()
install_finished(Array)
install_run_task(Array, Array)
install_run_tasks(Array)
install_drupal()
Notice: Trying to get property of non-object in locale_translation_source_check_file() (line 173 of core/modules/locale/locale.translation.inc).
locale_translation_source_check_file(Object)
locale_translation_batch_status_check('drupal', 'fr', Array, Array)
call_user_func_array('locale_translation_batch_status_check', Array)
locale_translation_worker(Array)
call_user_func_array('locale_translation_worker', Array)
Drupal\Core\Cron->processQueues()
Drupal\Core\Cron->run()
install_finished(Array)
install_run_task(Array, Array)
install_run_tasks(Array)
install_drupal()
Notice: Trying to get property of non-object in locale_translation_source_check_file() (line 174 of core/modules/locale/locale.translation.inc).
locale_translation_source_check_file(Object)
locale_translation_batch_status_check('drupal', 'fr', Array, Array)
call_user_func_array('locale_translation_batch_status_check', Array)
locale_translation_worker(Array)
call_user_func_array('locale_translation_worker', Array)
Drupal\Core\Cron->processQueues()
Drupal\Core\Cron->run()
install_finished(Array)
install_run_task(Array, Array)
install_run_tasks(Array)
install_drupal()

but just reloaded the pages to keep going. In the end, the public-facing theme is a bit messed up though admin theme looks fine.

penyaskito’s picture

@Kristen: The problem with the theme happens with a regular installation when choosing a non-English language too.
Filled #2331991: Theme missing when installing in non-English language.

Kristen Pol’s picture

@penyaskito Oh! Good to know. :) I won't stress about that one for the moment then and move onto other things. Thanks!!!!

Gábor Hojtsy’s picture

#2331991: Theme missing when installing in non-English language landed, so the theme should not be a problem anymore.

Kristen Pol’s picture

StatusFileSize
new32.77 KB

I did the following:

  1. Updated to latest core dev
  2. Updated to latest d8ml profile code/config
  3. Tried going through installer and it gets stuck

Here's a screenshot:

I then copied some of my latest config from temp_config (without the uuids) and was able to get through installer by refreshing page a few times here and there but it shows some errors and has the theme issue.

I then copied all of my latest config from temp_config (without the uuids) and it totally breaks.

So... I'm confused.

@Gabor - You mentioned you had luck "fixing" the config but it isn't working for me (it stalls). Did you do any other magic to your core code to get the installer to work without errors?

Gábor Hojtsy’s picture

I just reinstalled again my copy of the multilingual demo profile (5 Sept 2014, we only had one commit on that day :) with a fully up to date Drupal 8 head and it almost entirely works. The installer goes through properly, at the end, the site has some notices, namely: Notice: Trying to get property of non-object in locale_translation_source_check_file() (line 173 of core/modules/locale/locale.translation.inc). which is probably down to the install profile code not being updated to current Drupal 8 expectations about passing a project object. But this does not make it not install, in fact the first time I see errors is this time and its already displaying the site.

(I don't think any of the commits since then should have caused issues for installation either).

What we can do to have an independent site environment to test is to branch master to 8.x-1.x and then it will be possible to launch simplytest.me test sites with the profile. Hopefully :) I'll do that but then we need to agree to use that branch going forward and NOT master.

Gábor Hojtsy’s picture

Switched to 8.x-1.x (REMOVED THE MASTER BRANCH!). So now http://simplytest.me/project/2267517/8.x-1.x would ideally work. It says it has issues downloading dependencies. Not yet sure what would those be, but once those are resolved, theoretically this should help check in an independent environment.

Gábor Hojtsy’s picture

Opened #2335995: mutilingual demo 8.x failed downloading dependencies on simplytest.me for simplytest.me BUT it works for me locally, so I suggest cleaning up your local environment. Eg. both the profile and D8 contrib have git_deploy for some reason, I am not sure if your install uses the profile one or the contrib one?

Gábor Hojtsy’s picture

http://simplytest.me/project/2267517/8.x-1.x should now work with a few notices about translations. But it installs. Will debug the notices later and fix them. The info I have for now is there are no local files for translations but it wants to use those. That does not work out well... BUT it installs, it shows that the distro with the core patch works well installing and does not have the errors you screenshot.

Gábor Hojtsy’s picture

FYI opened #2336743: When more than one language is added in the profile, the installer ignores those as a core issue to deal with multiple languages in the installer. Core should do this without more tasks added or outside code needed in the profile.

Gábor Hojtsy’s picture

All right updated the profile to use the patch from #2336743: When more than one language is added in the profile, the installer ignores those so no extra code needed, no additional installer steps, etc. Just ship with the extra languages and core takes care of it. (With that patch). We'll need to see if any tests are possible to add to that one, but that is the complete changeset needed on core to make it work. Better for future profile developers.

I think this can be closed now? Its great we are finding and resolving core issues with this profile :) Its unfortunate there are so many to resolve...

Gábor Hojtsy’s picture

In other words if you go through http://simplytest.me/project/2267517/8.x-1.x, then it should fully install in your selected language (regardless of English or something else) and French + Spanish . There is a brief notice for a version number from an .info file, but other than that it works very well.

Kristen Pol’s picture

Wow! That is amazingly awesome!!!! :) Ok... I'll get all squared away with new patch, etc.

Gábor Hojtsy’s picture

Yeah to be clear, this removed ALL the added tasks in the *.profile and now core natively does this due to you shipping with some language.entity.* files :) I mean natively with that patch :D

Kristen Pol’s picture

I'm going to get myself sorted right now.

Kristen Pol’s picture

Title:Figure out how core interface translations and custom string (config) translations can be included in install» Figure out how core interface translations can be included in install

I'm changing the title of this one as the config strings still don't get sucked in so I'll make a separate issue for that one.

Status:Fixed» Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.