Problem

English is a special cased language in Drupal, cannot be removed on single language foreign language websites and cannot be customized/translated. Whether English is something people should be able to translate Drupal to could be a question debated. In practice, Drupal is written in some kind of English but there is no one single kind of English. Translators like @andypost have separate Russian translations for educational and government sites. Many of the UI wording used can be different based on the territory, target audience, etc. Whether you do this as part of translation to an entirely different language or a different flavor of English is really a detail.

Also, Drupal has one single language list. When you have an enabled entry for English, it means you can submit nodes related to that language, set up a customized date format for that language, etc. All those user edited content can be in any flavor of English, but as of yet, the UI cannot be. People needed to set up an "en-custom" to do the same to the interface. So English is only a special case for the interface, not for the content. People have increasingly less understanding of what's interface and content really, and just want to work with it and customize it. Why not make it work universally.

The main reason English is special cased is to speed up t() lookups given we do know you have no UI translations there. We can achieve a very similar effect by looking at whether you had translations and not look in the database if you did not have any. Making English deletable would only allow to simplify the single-language experience, where English is not needed if you run a foreign language site.

Proposed resolution

Make English a first class language like any other. You can delete it, you can translate Drupal to it, etc. We need to introduce (for the interface translation only) a language level behind this then, which I named with the pseudo language code "built-in". This is used to skip t() lookups entirely or search in built-in text on the locale UI (both of which used 'en' for this before).

User interface changes

Parent issue

#1260690: META: Improve multilingual user experience in Drupal 8

CommentFileSizeAuthor
#80 make-english-first-class-1266318-80.patch17.07 KBgábor hojtsy
#78 make-english-first-class-1266318-78.patch17.27 KBgábor hojtsy
#74 make-english-first-class-1266318-74.patch17.3 KBalberto56
#71 make-english-first-class-1266318-71-a.patch16.89 KBalberto56
#71 make-english-first-class-1266318-71-b.patch17.04 KBalberto56
#65 make-english-first-class-1266318-64.patch15.9 KBalberto56
#62 Screen shot 2011-10-21 at 11.27.28 AM.png82.45 KBalberto56
#61 make-english-first-class-1266318-61.patch14.21 KBgábor hojtsy
#59 make-english-first-class-1266318-59.patch14.17 KBgábor hojtsy
#56 make-english-first-class-1266318-56.patch14.19 KBgábor hojtsy
#54 make-english-first-class-1266318-54.patch14.59 KBgábor hojtsy
#52 make-english-first-class-1266318-52.patch14.92 KBgábor hojtsy
#50 make-english-first-class-1266318-50.patch15 KBgábor hojtsy
#47 make-english-first-class-1266318-47.patch15 KBalberto56
#45 make-english-first-class-1266318-45.patch15 KBgábor hojtsy
#36 make-english-first-class-1266318-36.patch15.21 KBgábor hojtsy
#32 make-english-first-class-1266318-32.patch13.41 KBgábor hojtsy
#24 make-english-first-class-1266318-24.patch13.36 KBgábor hojtsy
#23 make-english-first-class-1266318-23.patch13.35 KBgábor hojtsy
#20 make-english-first-class-1266318-20.patch12.4 KBalberto56
#12 Languages-Admin-Page.png62.89 KBemarchak
#9 make-english-first-class-1266318-9.patch8.39 KBDavid Lesieur
make-english-first-class.patch8.4 KBgábor hojtsy
TranslateFilterEnglish.png125.43 KBgábor hojtsy
TranslateEnglish.png72.42 KBgábor hojtsy
LanguagesEnglish.png95.46 KBgábor hojtsy

Comments

Status: Needs review » Needs work

The last submitted patch, make-english-first-class.patch, failed testing.

jherencia’s picture

Subscribe.

jwilson3’s picture

subscribe.

podarok’s picture

subscribe

its like a hook_alter %)
possibly we have to provide translation layers for this?
Language merging for different modules with different weight

gábor hojtsy’s picture

@podarok: I don't understand your comment, please elaborate.

podarok’s picture

If we provide multiple languages at site with different styles possibly we can provide some layers for them

example module commerce with UA translation for government and more freestyle UA translation
merging theese translations in different way per-module base would be nice... possibly...

gábor hojtsy’s picture

@podarok: well, for now layers of language (translation) customization is not in the plans for now. Anyway, that would be a job of another issue.

David Lesieur’s picture

Issue tags: +montreal

Some suggestions that arose from discussions at the code sprint:

  • Use "System language" as a label, instead of "Built-in interface text".
  • On the Languages page, add a row for the System language (with no operations).
David Lesieur’s picture

StatusFileSize
new8.39 KB

Patch no longer applied. Re-rolled it and changed system language label. I'm not convinced about adding the system language to the Languages page.

However it seems to breaks the tests — all the tests — when trying to run any test while Locale is enabled. I did not investigate this. Perhaps a similar issue to #276153: Testing does not work at all when locale of host session is not English.

gábor hojtsy’s picture

Status: Needs work » Needs review

Interesting. The above patch only failed 3 times, not wholesale. Hm. Looking for testing feedback here then (marking needs review for that).

Status: Needs review » Needs work

The last submitted patch, make-english-first-class-1266318-9.patch, failed testing.

emarchak’s picture

StatusFileSize
new62.89 KB

I posted a mockup of the discussions we had at the Montreal coding sprint in #1260860: Rework language list admin user interface. There are a few other items on the page, but the system language as default is displayed as locked to the bottom and greyed out so users have a representation of what's going on.

I'm including it here for at least clarity's sake. So many issues are on this topic!

alberto56’s picture

subscribing

jose reyero’s picture

I love this. Translating English to English :-)

Btw, there's some issue that arises with allowing customizing English strings: when you translate to another language the 'source' string displayed to the translator (if translating from English) needs to be the customized English string, not the source-hardcoded string.

* Which btw, will render our translations useless for contributing them back so we'll need to carefully handle this later. I.e. no option to push back to server translations of customized strings.

And then, why not being able to choose the source language for translating? Once you start customizing strings, the main 'source language' may not be English, but any other. The source language should be your primary site language, which is the one you are supposed to start customizing strings in, then they'll need translation to English.

gábor hojtsy’s picture

@Jose: yes, well, those are great goals, but I think if we can just get rid of English as a specialty first and then see what can be done later for improving the UI translation workflow, that would be great. Just making English the same level as others would already open the floodgates for stuff people used to customize Drupal for in awkward ways, so its not getting any worse :) People used to do en-my or en-custom or en-us or something to do this, and their other translations did not use that as source either. I think a simpler solution to your request would be to be able to see one other language on translation when you translate, and in fact, the core translation UI displays all languages at once, so you can just tell your staff to look at the translated English instead of the built-in English. That you can already do in Drupal 6 with en-us, en-my, etc. so I don't think that is a new problem there.

alberto56’s picture

"The above patch only failed 3 times", true, in the testbot. But applying this patch to to 8.x-dev and running the "Language configuration" test on my laptop throws an exception without even running.

An AJAX HTTP error occurred. HTTP Result Code: 500 Debugging information follows. Path: /batch?render=overlay&id=4&op=do StatusText: Service unavailable (with message) ResponseText: Additional uncaught exception thrown while handling exception.OriginalPDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'd8mi2.locales_source' doesn't exist: SELECT s.lid, t.translation, s.version FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid AND t.language = :language WHERE s.source = :source AND s.context = :context; Array ( [:language] => en [:source] => @count passes [:context] => ) in locale() (line 666 of /Applications/MAMP/htdocs/d8mi/modules/locale/locale.module).AdditionalPDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'd8mi2.locales_source' doesn't exist: SELECT s.lid, t.translation, s.version FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid AND t.language = :language WHERE s.source = :source AND s.context = :context; Array ( [:language] => en [:source] => %type: !message in %function (line %line of %file). [:context] => ) in locale() (line 666 of /Applications/MAMP/htdocs/d8mi/modules/locale/locale.module).

I therefore can't for now reproduce the errors from the testbot on my personal dev site. Investigating; David's comment in #9 seems relevant: something in Simpletest requires the system language to be "en" and everything breaks when system language is something else. However, why does a local test break and not the testbot? Looking into it.

sylvain_a’s picture

Suscribing.

webchick’s picture

Great work on this issue, folks!

I think this general approach definitely makes sense, as long as it's transparent to English sites what's going on under the hood. Being able to provide "Better English" translations for Drupal using the same tools as you provide other translations makes a lot of sense, too. Thanks for the walk-through of this at the sprint, Gábor, and great job on the mockups, Erin!

alberto56’s picture

To reproduce the testing errors from the testbot on my local dev site, I must change "built-in" back to "en" on line 1469 of includes/bootstrap.inc, after having applied the patch.

alberto56’s picture

StatusFileSize
new12.4 KB

More on the tests:

The enclosed patch should only fail twice instead of three times.

- the reason why it is not possible to translate in the UI of a local is because the t() function throws an exception during the installation phase of certain tests, making it seem as if all tests are broken.
- in reality there seem to be only three broken tests in the patch on #9, above:
- the first is quite straightforward and has been addressed in the patch I am submitting now: instead of asserting that english can't be deleted, assert that english *can* be deleted (but to do that I had to add a new language first and make that the default) -- there's probably some cleaning up to do in that test.
- the other two I'm having a hard time getting my head around, but it has to do with t() being called at some point when the tables associated with the locale module have not yet been created.

Cheers,

Albert.

idflood’s picture

sub

reglogge’s picture

subscribe

gábor hojtsy’s picture

StatusFileSize
new13.35 KB

@alberto56: thanks for your great work on this patch. I took your last patch and made a few changes to it:

1. I've defined LANGUAGE_SYSTEM to hold the language code for the "System (English)" language, and changed that language code to system. (Not sure a shorter code like sys would not collide with real languages in the future).
2. Changed locale_install() to use the new locale_language_save() function and added a todo to figure out how NOT to add English if we are installing a foreign language site (ie. in the installation process). If you enable locale after the installation process, it should always add English, since all your existing content types, etc. are supposedly English (or at least whatever language_default() said earlier).
3. Changed the system language label to "System (English)".
4. I'm not in agreement that the drupal_web_test_case.php code should change the global $language to the system language. That has serious implications outside of this scope, and should not be a practice we promote IMHO. Eg. that language is used to save nodes, etc. So let's keep that 'en'. If as the comment says it causes utf8_truncate() and/or t() to cause problems, let's fix that instead IMHO. Added a @todo for that.

Thanks for your great work so far! Are you interested in bringing this forward?

gábor hojtsy’s picture

StatusFileSize
new13.36 KB

Now that I can access git, here is a reroll that does not have any offsets. Applies even cleaner.

clemens.tolboom’s picture

Please unlock the issue as #19 is still valuable for reviewers right?
I wanted to add comment #19 into the summary by http://drupal.org/node/1266318/edit

Nice work btw :-)

gábor hojtsy’s picture

@clemens.tolboom: well, I guess the issue summary uses an input format you don't have access to. If I set it a lower format, the images will not show. Can we figure out why is the hack in #19 required, to avoid it in a future version of the patch instead?

clemens.tolboom’s picture

Strange and kinda scary as there are privileged d.o users for issue summary ... wtf ... I'm working on this tiny dreditor #1277974: Button to prepend the 'Issue summary standard' template into Issue body.

And yes we need to fix the patch too :-)

gábor hojtsy’s picture

@clemens.tolboom: edited the post to take advantage of the new local image filter feature. Now you can edit it, so please keep your comments on topic. Your feedback and work on the patch is more than welcome!

clemens.tolboom’s picture

I applied #24 then on a fresh d8

drush --yes site-install
drush --yes en locale

PHP Fatal error:  Call to undefined function locale_language_save() in /Users/clemens/Sites/drupal/d8/www/modules/locale/locale.install on line 19
PHP Stack trace:
PHP   1. {main}() /Users/clemens/.drush/drush/drush.php:0
PHP   2. drush_main() /Users/clemens/.drush/drush/drush.php:41
PHP   3. drush_dispatch() /Users/clemens/.drush/drush/drush.php:101
PHP   4. call_user_func_array() /Users/clemens/.drush/drush/includes/command.inc:214
PHP   5. drush_command() /Users/clemens/.drush/drush/includes/command.inc:0
PHP   6. _drush_invoke_args() /Users/clemens/.drush/drush/includes/command.inc:806
PHP   7. call_user_func_array() /Users/clemens/.drush/drush/includes/command.inc:134
PHP   8. drush_pm_enable() /Users/clemens/.drush/drush/includes/command.inc:0
PHP   9. drush_module_enable() /Users/clemens/.drush/drush/commands/pm/pm.drush.inc:708
PHP  10. module_enable() /Users/clemens/.drush/drush/commands/core/drupal/environment.inc:103
PHP  11. module_invoke() /Users/clemens/Sites/drupal/d8/www/includes/module.inc:448
PHP  12. call_user_func_array() /Users/clemens/Sites/drupal/d8/www/includes/module.inc:795
PHP  13. locale_install() /Users/clemens/Sites/drupal/d8/www/includes/module.inc:0
Drush command terminated abnormally due to an unrecoverable error.                         [error]
Error: Call to undefined function locale_language_save() in /Users/clemens/Sites/drupal/d8/www/modules/locale/locale.install, line 19

On admin/config I get

Notice: Undefined index: en in locale_get_plural() (line 716 of /Users/clemens/Sites/drupal/d8/www/modules/locale/locale.module).
Notice: Trying to get property of non-object in locale_get_plural() (line 716 of /Users/clemens/Sites/drupal/d8/www/modules/locale/locale.module)

-- my 2 cents

clemens.tolboom’s picture

+++ b/modules/locale/locale.pages.inc
@@ -191,7 +188,7 @@ function locale_translation_filters() {
-    'options' => array_merge(array('all' => t('All languages'), 'en' => t('English (provided by Drupal)')), $languages),
+    'options' => array_merge(array('all' => t('All languages'), LANGUAGE_SYSTEM => t('System (English)')), $languages),

"System (English)" feels weird. What about "Internal (English)"?

I agree "System (English)" is better then "English (System)"

+++ b/modules/locale/locale.test
@@ -170,11 +170,47 @@ class LocaleConfigurationTest extends DrupalWebTestCase {
-    $this->assertText(t('The English language cannot be deleted.'), t('Failed to delete English language.'));
+    ¶
+    $this->drupalPost('admin/config/regional/language/delete/en', array(), t('Delete'));

Whitespace

gábor hojtsy’s picture

On the locale_language_save(), not sure how I had that working, its in locale.inc, should be included at that point: http://api.drupal.org/api/drupal/includes--locale.inc/function/locale_la...

gábor hojtsy’s picture

Status: Needs work » Needs review
StatusFileSize
new13.41 KB

Here is an updated patch which now includes locale.inc on locale_install() and fixes the whitespace. @clemens: this should fix the missing function and should fix the undefined index too, since it should actually add English.

Status: Needs review » Needs work

The last submitted patch, make-english-first-class-1266318-32.patch, failed testing.

catch’s picture

Subscribing. Patch looks lovely so far.

alberto56’s picture

Hi all, while working on this I have installed a few d8 instances, and when I try to install Drupal in a language other than English (with or without this patch), I get

Call to undefined function _locale_import_read_po() in ../includes/install.inc on line 1113

That error seems unrelated to this patch: I have documented it here and submitted a patch to fix it, in case you come across the same problem:

http://drupal.org/node/1297506#comment-5066302

Cheers, and thanks to everyone for your work,

Albert.

gábor hojtsy’s picture

Status: Needs work » Needs review
StatusFileSize
new15.21 KB

Updated patch includes optimization to only look up translations for those where translations do exist in the database (note that the previous $custom_strings[$options['langcode']] hacks used by string_overrides work just like before). This is my testing fixes 2 of the 4 failures, only leaving path alias failures in. Not sure yet why are those happening. @alberto56: can you land a helping hand to look into that? Setting to needs review for testbot and any human reviewers. I hope this is getting pretty close :)

Status: Needs review » Needs work

The last submitted patch, make-english-first-class-1266318-36.patch, failed testing.

gábor hojtsy’s picture

Well, turns out this is not so simple. The new test fails are due to t() now not saving new strings until the first string translation for the language is saved some other way, since now t() is gated on whether there is any string for that language saved already. Looks like we need to be smarter here. Any ideas welcome.

alberto56’s picture

Regarding the paths, it seems that with this patch, Dupal adds the 'en' prefix when it should not, in many circumstances. For example, on the 12th screenshot of LocalePathFunctionalTest (see sites/default/files/simpletest/verbose/LocalePathFunctionalTest-12.html once you run your test), we see

Existing system path *
http://localhost/english-d8/drupal8patched_FR/?q=en?q=

Notice ?q=en?q=, which is just plain ugly.
The LocalePathFunctionalTest fails also later on, the "First node links to the path alias." assertion. Given an alias "whatever" for node/1, the test expects the link to render as whatever for english, but it renders as en/whatever. Looking into this.

alberto56’s picture

update on comment 39: after a few tries, I can't reproduce this when I'm actually using the site, only in the automated tests. To be continued.

gábor hojtsy’s picture

@alberto56: that might have something to do with our change to use locale_language_save() in locale_install() which will use the 'en' prefix for English to set it up. If we specifically provide an empty path prefix there, it should behave like before and not set path prefix for English out of the gate. IMHO. Not tested.

alberto56’s picture

Hi all,

Regarding paths, a few notes:

(1) scrap my comment at #40: when reproducing exactly what's in the test (including non-clean URLs), this can be reproduced.

(2) I have tracked down the function that adds the "en" prefix when it probably should not: it is locale_language_url_rewrite_url() in includes/locale.inc. Specifically, the lines

      case LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX:
        if (!empty($options['language']->prefix)) {
          $options['prefix'] = $options['language']->prefix . '/';
        }
        break;

.

It seems locale_language_url_rewrite_url() should not be adding a prefix if we are dealing with the default language.

gábor hojtsy’s picture

@alberto56: no, the prefix should be dependent on your configuration. If you wanted to have prefix for the default language, you'll provide one, if you don't want to have that, you'll not provide one. That it is. As I wrote above, IMHO the change in locale_install() to create English with our new API function made it have a path prefix. In effect, http://api.drupal.org/api/drupal/includes--locale.inc/function/locale_la... does set a prefix to the langcode if it was not set otherwise and the previous SQL query did not include a prefix, so that changes behavior for setting up English right there. If you change the locale_install() code to specify prefix => '' then it should behave like before. Can you work forward with that? Thanks!

alberto56’s picture

@gabor thanks for the comment. I better understand it now. I'll be on a trip for the coming week, so I'll gladly look at this upon my return.

One thought though: if the prefix for english is '', then when another language than English is set to be the default, won't it be impossible to move back to English when language negociation is set to "path prefix"? In that sense, I'm not clear on whether it is actually a good idea to set the prefix of English to ''.

Cheers,

Albert.

gábor hojtsy’s picture

Status: Needs work » Needs review
StatusFileSize
new15 KB

@alberto56: we had that debate many times before. It is also independent of English. Whether people want to have a prefix for their default language or not is a personal choice dependent on the project. People should not change default languages much but when they do, they can reconfigure prefixes if they want to. Usually people want URLs to not change (avoid linkrot, maximize SEO, etc), so when they enable locale module to add languages to an existing English language site let's say, they explicitly want it to not change their existing URLs => no prefix added for English when locale module is enabled.

Along these lines, I've modified locale_install() to just take the values direct form language_default(). This allows locale module to adapt to sites where the default language was changed before locale module was enabled (which is even possible in D7). Let's see how this tests.

alberto56’s picture

@gabor thanks! I'm not (yet!) too well versed in the internationalization system so your explanation is appreciated. If you have a link to the discussions around this, please pass them on here.

I corrected a typo on your patch: you had langugae_default(), I put language_default() instead.

For those (such as myself) wondering why the testbot displays "PASSED" when there are "0 pass(es)": see http://drupal.org/node/873496

Cheers,

Albert.

alberto56’s picture

...and here is your patch with the correction.

Status: Needs review » Needs work

The last submitted patch, make-english-first-class-1266318-47.patch, failed testing.

gábor hojtsy’s picture

Prefix for English was discussed in #146084: Default path prefix for English (and DBTNG it) among other places. You can google for more. Let's not overload this issue with that though. There was no prefix before this patch, so there should be no prefix after either. We are making big enough of a change here. Can you look at fixing the test failures?

gábor hojtsy’s picture

Status: Needs work » Needs review
StatusFileSize
new15 KB

Rerolled due to offsets for changes in how languages were saved. Looking for test feedback.

Status: Needs review » Needs work

The last submitted patch, make-english-first-class-1266318-50.patch, failed testing.

gábor hojtsy’s picture

Status: Needs work » Needs review
StatusFileSize
new14.92 KB

Some of the new code in the test still used the prefix field on the add language form, which is not there anymore. Removing that.

Status: Needs review » Needs work

The last submitted patch, make-english-first-class-1266318-52.patch, failed testing.

gábor hojtsy’s picture

Status: Needs work » Needs review
StatusFileSize
new14.59 KB

All right, took another stab at this performance problem. Since autodetecting whether you want English or not in translation did not really work (the source strings are never saved, so you cannot in fact translate stuff to English, unless you also have another language on the site AND you browse around in that language, which should not be a requirement), we need to make this an explicit setting. I'm not very happy about introducing that at this stage, BUT there has been lots of talk about refactoring the "enabled" feature for languages, so I've opened an issue for that at #1314250: Allow filtering/configuration of which languages apply to what (UI, nodes, files, etc), where we can migrate this approach later. That would make English even less special, since you'd ask for a list of languages for "ui translation" or "ui language switching", etc, and it would filter the language list based on your settings. However, we can just make this an incremental change now and come back to that larger issue later and include migrating our simple setting here to that.

So let's see this approach, what do you think and what does the testbot think?

Status: Needs review » Needs work

The last submitted patch, make-english-first-class-1266318-54.patch, failed testing.

gábor hojtsy’s picture

StatusFileSize
new14.19 KB

The test fails are all valid. (1) We have some outdated additions in our test that look for the old language list pieces. That was updated. (2) Search test looks for English as non-translated, but should look for the System (English) language. Should pass tests now I think.

idflood’s picture

Status: Needs work » Needs review

let's trigger the testbot

gábor hojtsy’s picture

All right, I think this is as good UX/DX as we can get for now until #1314250: Allow filtering/configuration of which languages apply to what (UI, nodes, files, etc) can be figured out, when that patch will inherit the responsibility to exclude languages from UI translation (not limited to English). Since that is still some ways off and this is already a sizable improvement and does not enforce the functionality on any upgraders, I'd like to propose to get this approach in. Reviews please!

gábor hojtsy’s picture

StatusFileSize
new14.17 KB

Rerolled. It did nto apply in one hunk. Same patch, would love to see reviews.

Status: Needs review » Needs work

The last submitted patch, make-english-first-class-1266318-59.patch, failed testing.

gábor hojtsy’s picture

Status: Needs work » Needs review
StatusFileSize
new14.21 KB

New patch did not provide the predefined_langcode in the test like other tests do (add langauge patch rework was committed in the meantime). This should fix it and pass again.

alberto56’s picture

Status: Needs review » Needs work
StatusFileSize
new82.45 KB

Hi all,

I did a few (manual) tests with the latest patch:

- I installed two 8.x (latest dev), one with the patch at 47, one with the patch at 61
- I installed both sites in French.

Trying to figure out where to set "locale_translate_english" in the UI.

Albert.

alberto56’s picture

Status: Needs work » Needs review

oops

gábor hojtsy’s picture

Yes, you can find the checkbox to be checked **on the English language editing page** to enable it for translation. This is needed for performance reasons. See above discussion on that.

alberto56’s picture

StatusFileSize
new15.9 KB

Perhaps the "allow translation to English" should be in the language list page (seems more intuitive). Other than that, the patch at #61 works fine both for French and English installations.

Here's a modified version of the patch at 61 which adds some simpletest validation:

- makes sure we can't translate strings to english by default
- makes sure the string translation page has a field allowing the translation of a string to english once you checked "enable interface translation to english" on admin/config/regional/language/edit/en

This test makes sure it is possible to enter a value in English for a string on the site. Ideally we would also test that this actually works. (manual tests show it does: an automated test would be good).

Albert.

gábor hojtsy’s picture

@alberto56: yes, once again the enabled checkbox placement problem is covered above, that we'd ideally refactor the enabled checkbox on language list to let you enable stuff for certain things, and I've linked in #1314250: Allow filtering/configuration of which languages apply to what (UI, nodes, files, etc) above for that (and we already have some discussion there, but it is a bit far reaching). So yes, it would be great to have it there, I agree, but it does not make sense to have there at the moment as-is.

I think it would be relatively easy to test that the translation was saved, you can just (a) go back to the page and check if the form has it pre-loaded or (b) you can use t($string, array(), array('langcode' => 'en')) and verify you get back the translation. Can you work on adding those and do you think anything else is missing for now? Thanks!

gábor hojtsy’s picture

@alberto56: can you work on that and help bring this through the final stretch? Thanks!

alberto56’s picture

@Gábor yes, taking a look at that this morning.

Cheers,

Albert.

clemens.tolboom’s picture

Is it possible to update the issue summary with a step through guide? I myself always get lost in all pages :(

Especially when to enable a second language? What install steps to check? I'll try to review later this week.

gábor hojtsy’s picture

@clemens.tolboom: the exact screenshots changed a bit from the originals, but you basically enable locale module; what you should see right away different from before the patch is that you can delete English (if it is not the current default language); you can add back English after that on the Add language page and then go to edit English and you'll see a new checkbox with which you can enable English for interface translation. Then you should be able to change strings in English and those strings should show up as changed on English pages. That is the whole extent of the functionality of this patch. The specific enabling of English for UI translation is for performance reasons and also to avoid some UI WTFs people might have. Good summary for testing?

alberto56’s picture

Hi all,

I have attempted to improve the testing here so that we can confirm that translating a string to English actually works.

- I can confirm after manual testing that translating a string from the system language to English works.
- I have added a test which revisits the string translation page after having put in a translation for English, and confirming that the translation is still present.
- However, calling t($string, array(), array('langcode' => 'en')), as suggested by Gábor in comment 66, does not seem to work during testing; it returns the original string and not the translated string.

I am including two patches here:

- patch (A) should pass all tests -- it differs from the patch in 65 in that it revisits the string translation page, confirming that the translation to English is persistent, among other (trivial) tests.
- patch (B) fails once -- the following line fails:

$this->assertTrue($name != $translation_to_en && t($name, array(), array('langcode' => 'en')) == $translation_to_en, t('t() works for English.'));

Within the context of the test, the static locale_t within the locale() function does not contain the correct information, making the above code return the original string for 'en' even if a translation exists. To make the test (B) pass,
- apply the patch
- In locale.module's locale() function, after $locale_t = &drupal_static(__FUNCTION__);, add $locale_t['en'] = NULL;
- run the tests.
I'm not quite sure what to make of this, so your thoughts are welcome!

Albert.

alberto56’s picture

Status: Needs review » Needs work

Setting to needs work until we can explain why the patch at 71-b fails once. Feel free to set back to needs review if that is the standard when the functionality needs review but the test needs work.

Albert.

gábor hojtsy’s picture

Yes, locale() has its internal cache and since you use the t() call in simpletest (which runs in the same HTTP request, unlike drupalGet() and drupalPost() that actually run HTTP requests), you'd need to include the drupal_static() based locale() cache clearing as you explained in your comment. It is just the nature of how simpletest works in one HTTP request calling out with HTTP requests to Drupal. So you can just do this:

// Refresh the locale() cache to get fresh data from t() below. We are in the same
// HTTP request and therefore t() is not refreshed by saving the translation above.
locale_reset();
// Now we should get the proper fresh translation from t().
$this->assertTrue($name != $translation_to_en && t($name, array(), array('langcode' => 'en')) == $translation_to_en, t('t() works for English.'));
alberto56’s picture

Status: Needs work » Needs review
StatusFileSize
new17.3 KB

@Gábor thanks! I was scratching my head over that. So here's an updated patch which passes all tests.

gábor hojtsy’s picture

Status: Needs review » Reviewed & tested by the community

All right, I think this is the best we can do here for now. We'll refactor the 'enabled' language property in #1314250: Allow filtering/configuration of which languages apply to what (UI, nodes, files, etc) which will make the user experience (and even the developer experience) better here. For now, this patch allows us to not add English for foreign language installs, which helps with further work on #1260716: Improve language onboarding user experience and other related issues. Thanks for all the testing and added automated tests!

catch’s picture

Issue tags: -Usability, -D8MI, -montreal

Status: Reviewed & tested by the community » Needs work
Issue tags: +Usability, +D8MI, +montreal

The last submitted patch, make-english-first-class-1266318-74.patch, failed testing.

gábor hojtsy’s picture

Status: Needs work » Needs review
StatusFileSize
new17.27 KB

Due to the native name removal, one hunk did not apply to locale.install anymore. Here is a reroll. Otherwise untouched.

Status: Needs review » Needs work

The last submitted patch, make-english-first-class-1266318-78.patch, failed testing.

gábor hojtsy’s picture

Status: Needs work » Needs review
StatusFileSize
new17.07 KB

Well, the added tests should also not try to work with the native name field for languages, now that we don't have it on the UI. Just removing those couple lines from the test, otherwise leaving intact.

gábor hojtsy’s picture

Status: Needs review » Reviewed & tested by the community

Should still be RTBC given minimal changes applied.

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.x, thanks!

gábor hojtsy’s picture

Added change notice http://drupal.org/node/1323140 for this. Thanks!

clemens.tolboom’s picture

I somehow expected the issue summary 'Remaining Tasks' be empty.

As http://drupal.org/node/1323140 will direct users back to this issue it would be great to have a finished issue summary right?

clemens.tolboom’s picture

Use more permissive format now that local images are allowed.

gábor hojtsy’s picture

@clemens.tolboom: great catch. I've moved those to http://drupal.org/node/1260716#comment-5168080 to the installer task, where it is going to be resolved. It is still dependent on #1260586: Consolidate .po file import to one directory to get started, which is pretty close though.

Status: Fixed » Closed (fixed)

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

gábor hojtsy’s picture

Issue tags: +language-base

Tagging for base language system.

gábor hojtsy’s picture

Issue summary: View changes

Remove remaining tasks, now copied to http://drupal.org/node/1260716#comment-5168080