wagtail / wagtail-localize

Translation plugin for Wagtail CMS
https://wagtail-localize.org/
Other
222 stars 84 forks source link

DeepL target_lang for EN-GB and EN-US #738

Closed unreadableusername closed 9 months ago

unreadableusername commented 10 months ago

The DeepL API documentation specifies to use EN-GB or EN-US to archieve the desired translation, however following code in the deepl.py will chop off the -GB or -US and the deprecated unspecified route will be used.

def language_code(code, is_target=False):
    # DeepL supports targeting Brazillian Portuguese but doesn't have this for other languages
    if is_target and code in ["pt-pt", "pt-br"]:
        return code
    return code.split("-")[0].upper()

I suggest to add en-gb and en-us to the array inside the if statement above to respect users desired locale setting. Please tell me if this is shortsightet or more complicated then this 😅

zerolab commented 10 months ago

@unreadableusername I think the note on target_lang - "EN - English (unspecified variant for backward compatibility; please select EN-GB or EN-US instead)" is fairly clear. We should follow the advised approach. Do you have the capacity to submit a PR?

enzedonline commented 10 months ago

You'll get me started on a rant about EN being taken to mean EN-US when US English is a dialect of English only used in parts of North America 😂. European (and more) sites that use EN mean international English which definitely is not US English. It's a bit like using FR and getting Quebecois instead.

I've always thought there should be a configurable default locale when using language codes. Having to specify something like EN-GB in the url to get non-American English makes no sense and makes the reader it's something UK specific.

zerolab commented 9 months ago

Added tests and merged in a3efa8f Thank you