Skip to content
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

Translate default dictionaries #10972

Closed
andjsch opened this issue Oct 17, 2024 · 1 comment · Fixed by #10982
Closed

Translate default dictionaries #10972

andjsch opened this issue Oct 17, 2024 · 1 comment · Fixed by #10982

Comments

@andjsch
Copy link
Contributor

andjsch commented Oct 17, 2024

Bug description

Currently, if you view the CP in another language and use one of the predefined dictionaries, the labels are not translated. I think translating Countries and Currencies would be sufficient enough.

If this is something that would be considered for a merge, I'd be happy to provide a PR.

For the PR, it should be considered where to put the translations.

  • Either within the {lang}.json file, which would be convenient, but messy
  • Within a dictionaries.php file where the translated dictionaries are within an array
    • Countries -> countries.{iso2}
    • Currencies -> currencies.{code}

How to reproduce

Create a dictionary fieldtype within come blueprint and change the language to anything !English.

Logs

No response

Environment

Environment
Application Name: Statamic
Laravel Version: 11.28.1
PHP Version: 8.3.12
Composer Version: 2.5.8
Environment: local
Debug Mode: ENABLED
URL: statamic.test
Maintenance Mode: OFF
Timezone: UTC
Locale: en

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: NOT CACHED

Drivers
Broadcasting: log
Cache: file
Database: sqlite
Logs: stack / single
Mail: log
Queue: sync
Session: file

Statamic
Addons: 0
Sites: 1
Stache Watcher: Enabled (auto)
Static Caching: Disabled
Version: 5.31.0 PRO

Installation

Fresh statamic/statamic site via CLI

Additional details

No response

@jasonvarga
Copy link
Member

I'd do something like this:

resources/lang/en/dictionary-countries.php

<?php

return [
    'regions' => [
        'africa' => 'Africa',
        'americas' => 'Americas',
        'asia' => 'Asia',
        'europe' => 'Europe',
        'oceania' => 'Oceania',
        'polar' => 'Polar',
    ],
    'subregions' => [
        'southern_asia' => 'Southern Asia',
        // etc
    ],
    'names' => [
        'AFG' => 'Afghanistan',
        // etc
    ],
];
protected function getItems(): array
    {
        return [
            [
                'name' => __('statamic::dictionary-countries.names.AFG'), 
                'iso3' => 'AFG', 
                'iso2' => 'AF', 
                'region' => __('statamic::dictionary-countries.regions.asia'), 
                'subregion' => __('statamic::dictionary-countries.subregions.southern_asia'),
                'emoji' => '🇦🇫'
            ],
            // etc
        ];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants