-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Form] Allow to translate each language into its language in LanguageType #32388
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice ! I'd like to make it the default behavior if choice_translation_locale
is not provided, WDYT?
src/Symfony/Component/Form/Extension/Core/Type/LanguageType.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Form/Extension/Core/Type/LanguageType.php
Outdated
Show resolved
Hide resolved
}); | ||
}, | ||
'choice_self_translation' => false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about make it default true
if choice_translation_locale
is null
else set it to false
? that can be achieved with a lazy default function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You obtain root
from the language codes due
"root", |
It should be excluded.
However, strictly there's no co-relation between getNames
and getLanguageCodes
. The latter can have more codes. Consider getNames
the canonicalized list.
For the locales this is more obvious, see
symfony/src/Symfony/Component/Intl/Resources/data/locales/meta.json
Lines 569 to 570 in 09e3cef
"th_TH", | |
"th_TH_TRADITIONAL", |
Those are codes, but not available in the "canonicalized list of names".
Raises the question, should LocaleType
have this same option?
The option should be called choice_self_translate
IMHO, as it's an instruction.
👍 for the option, no real opinion if it should be default. Though http://www.flagsarenotlanguages.com/blog/best-practice-for-presenting-languages/ considers it a best practice 👍
🤔 that's confusing :) if you iterate getNames for codes it should be fine by default. |
This PR was squashed before being merged into the 4.4 branch (closes #32402). Discussion ---------- [Intl] Exclude root language | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | yes | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | #... <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | symfony/symfony-docs#... <!-- required for new features --> Spotted in #32388 Commits ------- 089cc06 [Intl] Exclude root language
The PR related to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@javiereguiluz Can you rebase on current master so that we can merge?
401ced0
to
2012677
Compare
Rebased. Thanks. |
Thank you @javiereguiluz. |
This would allow to set this option:
To display each language translated into its own language:
@ro0NL if this proposal is approved, could you please tell me why I must
try ... catch
with\Exception
?Symfony\Component\Intl\Exception\ResourceBundleNotFoundException
) the exception is not caught. Why?