area17 / twill

Twill is an open source CMS toolkit for Laravel that helps developers rapidly create a custom admin console that is intuitive, powerful and flexible. Chat with us on Discord at https://discord.gg/cnWk7EFv8R.
https://twillcms.com
Apache License 2.0
3.63k stars 560 forks source link

Missing ISO language names when setting locales in config/translatable.php #2619

Open armin-salihovic opened 4 weeks ago

armin-salihovic commented 4 weeks ago

Description

When adding certain locales in config/translatable.php, the ISO language names will appear only as the language code in the edit page.

Steps to reproduce

  1. enable translations
  2. add a locale that is missing to config/translatable.php, for example bs: 'locales' => [ 'en', 'bs', ],
  3. open the edit page in Twill and observe the save bar

Expected result

Correct display of the ISO language name.

Actual result

Missing ISO language name, e.g. in the edit page: image

Versions

Twill version: 3.0.0 Laravel version: 9.52 PHP version: 8.2

Suggested fix

I extracted the language codes that are missing. I suggest adding the following to the return of the function getCodeToLanguageMappings in src/Helpers/i18n_helpers.php to complete the code to language mappings:

'ak' => 'Akan',
'av' => 'Avaric',
'ae' => 'Avestan',
'bm' => 'Bambara',
'bs' => 'Bosnian',
'ch' => 'Chamorro',
'ce' => 'Chechen',
'ny' => ['Chewa', 'Nyanja'],
'cu' => 'Church Slavonic',
'cv' => 'Chuvash',
'kw' => 'Cornish',
'cr' => 'Cree',
'dv' => ['Maldivian', 'Dhivehi'],
'ee' => 'Ewe',
'ff' => 'Fulah',
'lg' => 'Ganda',
'ki' => 'Gikuyu, Kikuyu',
'hz' => 'Herero',
'ho' => 'Hiri Motu',
'ig' => 'Igbo',
'kr' => 'Kanuri',
'kv' => 'Komi',
'kg' => 'Kongo',
'kj' => ['Kuanyama', 'Kwanyama'],
'lb' => ['Luxembourgish', 'Letzeburgesch'],
'lu' => 'Luba-Katanga',
'mh' => 'Marshallese',
'nv' => ['Navaho', 'Navajo'],
'nd' => 'Northern Ndebele',
'ng' => 'Ndonga',
'se' => 'Northern Sami',
'nb' => 'Norwegian Bokmål',
'nn' => 'Norwegian Nynorsk',
'oj' => 'Ojibwa',
'os' => ['Ossetic', 'Ossetian'],
'pi' => 'Pali',
'sc' => 'Sardinian',
'nr' => 'South Ndebele',
'ty' => 'Tahitian',
've' => 'Venda',
'za' => 'Zhuang',