Problem/Motivation
When a language is added using the Add language page (admin/config/regional/language/add) a batch process is started to perform configuration translation. However when a language is added upon importing a po file new translation (admin/config/regional/translate/import) this process is not initiated.
Steps to reproduce
- Have a fresh Drupal installation with standard profile.
- Enable the Language and Interface Translation modules.
- Download a Dutch translation file from http://ftp.drupal.org/files/translations/8.x/drupal/drupal-8.0-alpha3.nl.po onto you own computer
- Import this translation file at admin/config/regional/translate/import
- Look for a batch process with the text "Completed x of 11". You will not find it.
- Add a language at admin/config/regional/language
- Look for a batch process with the text "Completed x of 11". You will find it.
Comments
Comment #1
Sutharsan CreditAttribution: Sutharsan commentedThis fixes the problem.
TODO Test: Needs an additional assertion in the manual import test to check for updated configuration.
Comment #3
Sutharsan CreditAttribution: Sutharsan commentedFixed the failing tests and added additional test assertions to detect the config update.
The patch locale-import-with-config-update-2095787-3-test-must-fail.patch only contains the new tests, not the patch.
Comment #4
Sutharsan CreditAttribution: Sutharsan commentedI currently can not figure out how to test whether the config translation is imported or not. Back to 'Needs tests'.
Comment #5
jhedstromComment #6
rpayanmComment #8
Gábor HojtsyComment #9
adci_contributor CreditAttribution: adci_contributor commentedTrying to fix Fatal Error in #6
Comment #10
Gábor HojtsyThanks! This should be possible to write tests for very similarly to InstallerTranslationMultipleLanguageTest in the current codebase. Take a string like 'Anonymous' and translate it in the imported .po file. Then verify it was updated. Without this patch it should not be, with this patch it should be. Look for the .po file snippet in InstallerTranslationMultipleLanguageTest and the test snippet at the bottom. Those should suffice to prove this test works in a .po import test.
Comment #11
Gábor HojtsyNeeds work for tests.
Comment #12
Gábor HojtsyComment #13
fran seva CreditAttribution: fran seva commentedComment #14
Gábor HojtsyTagging for sprint weekend.
Comment #15
DevElCuy CreditAttribution: DevElCuy commentedComment #16
DevElCuy CreditAttribution: DevElCuy commentedRemoved tag by mistake.
Comment #17
fran seva CreditAttribution: fran seva commented@Gabor I've been working in the test but I'm having problems getting the translated word.
Attach a draft with the patch.
Comment #18
Gábor HojtsyI think there are some minor problems that surely make this fail now and that will make this work :) Basically use the right source string in the .po and get() the right key from the config and you should be set. The rest are to remove extra stuff that you don't use:
Should have a short docblock.
You don't use these values, no need for them.
No need for this, see below.
Well you would get('anonymous'), the key of the value not the value :)
Should be "Anonymous" which is the shipped value in user.settings.yml, so it matches with the file.
Comment #19
fran seva CreditAttribution: fran seva commentedAttach test.
Comment #20
Gábor HojtsyFixed some minor code style and typos. Otherwise looked all good :) Thanks! Blocker for #2397281: Languages not translated when you add them.
Comment #21
Gábor HojtsyTest only patch also. Also fixing title to be more accurate.
Comment #22
Gábor HojtsyLol, that was a fix only, not a test only. Heh. Sorry.
Comment #24
alexpottThe is quite an ugly fix but given the state of the helper functions in the locale module I think it is acceptable. It is fixing the bug and adds tests. Tidying up the locale is separate and bigger issue. This issue is a normal bug fix, and doesn't include any disruptive changes, so it is allowed per https://www.drupal.org/core/beta-changes. Committed c4990fc and pushed to 8.0.x. Thanks!
Comment #26
Gábor HojtsyIndeed, the fix is ugly but that is as far as our current locale batch update API allows us to go. While it would be nice to refactor that (and batch building in general), that does not get us closer to Drupal 8 release, so we'll need to live with it for Drupal 8.