It would be a very small but nice usability enhancement if when uploading a .po file on admin/config/regional/translate/import it could auto-select 'Russian' if I was uploading a file named token-7.x-1.2.ru.po.

Comments

dave reid’s picture

Status: Active » Needs review
StatusFileSize
new2.87 KB

Status: Needs review » Needs work

The last submitted patch, 1744228-po-import-autoselect-language-code.patch, failed testing.

gábor hojtsy’s picture

Issue tags: +sprint, +language-ui

Good find, thanks will review later when I have time.

dave reid’s picture

Status: Needs work » Needs review
StatusFileSize
new2.81 KB

Ok, I shouldn't have tried to change the file upload field to a managed_file field.

dave reid’s picture

Ok this one should work.

dave reid’s picture

One more time. :)

bforchhammer’s picture

Assigned: Unassigned » bforchhammer

I'll have a look at this...

bforchhammer’s picture

Assigned: bforchhammer » Unassigned
Status: Needs review » Reviewed & tested by the community

Patch works as advertised. I tested it with a german translation file, and "German" is automatically selected in the language dropdown.

The patch also improves the help message for file-validation criteria by switching to theme_file_upload_help and adds the "maximum file size". Nice :)

Code looks clean and should be ready as far as I can tell.

webchick’s picture

Status: Reviewed & tested by the community » Needs work

Awesome UX improvement!

I found this comment confusing:

"+ * This only works if the file is named something.locale-code.po."

I think it should be more like:

"+ * This only works if the file name ends with "LANGCODE.po."

And then it occurred to me that we don't have a thing called "localeCode" and so this should be changed to "langCode" throughout to be consistent.

I asked nod_ & seutje to take a look at the new JS and they said:

seutje: if that behavior is executed again, it would have 2 identical change handlers, won't it?
nod_: yep
nod_: webchick: well, it's the right Drupal.stuff at least, code could use some work to make it prettier

Asked them to follow-up here with more details, they did emphasize it doesn't necessarily have to hold up the patch but if we can get it all in one go, then woot.

nod_’s picture

Issue tags: +JavaScript
StatusFileSize
new3.08 KB

For the future, If there is some js touched or added by a patch please add the JavaScript tag to the issue :)

Here is a reroll with kinda better JS. I added classes to the inputs as well, easier js selectors.

penyaskito’s picture

Status: Needs work » Needs review
StatusFileSize
new3.08 KB
new668 bytes

Changed localeCode for LANGCODE in js documentation.

Switched behavior name from importLocaleCodeSelector to importLanguageCodeSelector.

gábor hojtsy’s picture

Status: Needs review » Reviewed & tested by the community
dave reid’s picture

Status: Reviewed & tested by the community » Needs work

The JS here seemed to regress because if you upload a file with a language code that does not match the any of the available options, it will select the first option in the list. The expected result is that it should *not* change the option that is selected.

nod_’s picture

which browser?

dave reid’s picture

Chrome 21 and Firefox. We should not call .val() on an element which does not actually have that value. Why was that removed?

nod_’s picture

Status: Needs work » Needs review
StatusFileSize
new3.14 KB

nevermind, fixed, sorry about that. That'll teach me to try to be too smart :p

gábor hojtsy’s picture

Status: Needs review » Reviewed & tested by the community

Looks good again! :)

dries’s picture

A quick screenshot would be nice! :)

gábor hojtsy’s picture

StatusFileSize
new134.44 KB

Screenshot:
AutoLanguage.png

dries’s picture

Status: Reviewed & tested by the community » Fixed

Thanks. That helps. This looks handy, and code looks good so committed to 8.x. Thanks!

gábor hojtsy’s picture

Issue tags: -sprint

Removing from sprint. I don't think this should get a changelog entry or change notice, it is such a tiny improvement. Thanks all though!

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