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

Locales aren't migrated to sites as expected #90

Open
FrittenKeeZ opened this issue Aug 31, 2021 · 11 comments
Open

Locales aren't migrated to sites as expected #90

FrittenKeeZ opened this issue Aug 31, 2021 · 11 comments

Comments

@FrittenKeeZ
Copy link

In v2 our site/settings/system.yaml has these locales:

locales:
  da:
    name: Danish
    full: da_DK
    url: "{env:APP_URL}/"
  en:
    name: English
    full: en_US
    url: "{env:APP_URL}/en/"
  sv:
    name: Swedish
    full: sv_SE
    url: "{env:APP_URL}/sv/"

In v3 these are migrated to config/statamic/sites.php as:

    'sites' => [

        'default' => [
            'name' => 'Danish',
            'locale' => 'da_DK',
            'url' => '{env:APP_URL}/',
        ],

        'en' => [
            'name' => 'English',
            'locale' => 'en_US',
            'url' => '{env:APP_URL}/en/',
        ],

        'sv' => [
            'name' => 'Swedish',
            'locale' => 'sv_SE',
            'url' => '{env:APP_URL}/sv/',
        ],

    ],

I'd expect the key for Danish to be da instead of default.

A nice addition and helping hand, could be to convert the {env:APP_URL} part of URLs:

$url = preg_replace('/{env:([A-Z0-9_]+)}/', '{env(\'$1\')}', $url);
@FrittenKeeZ
Copy link
Author

I'm trying to rename default to da, renaming the respective content folders as well, then clearing cache, but the site just returns a 404 page - what am I missing?

@jasonvarga
Copy link
Member

Maybe you missed renaming the tree file?

@FrittenKeeZ
Copy link
Author

Doesn't seem like it - the site just responds with a 404 error
image

Globals has also been renamed

@jasonvarga
Copy link
Member

Where's the homepage? In the pages collection? (Probably)
Can you show content/collections/pages.yaml?

@FrittenKeeZ
Copy link
Author

That's it! I missed the collection structure changes 🙌

@jasonvarga
Copy link
Member

We dug into this. Looks like we intentionally change the first site to default. It was for a reason, but we can't find the reason, yet. 😆

@FrittenKeeZ
Copy link
Author

I guess it makes sense for single sites, but I'd imagine most multi sites use the key/handle for language selectors (with icons) like we do 🤷‍♂️

@jesseleite jesseleite added bug Something isn't working multisite and removed bug Something isn't working labels Sep 25, 2021
@FrittenKeeZ
Copy link
Author

@jesseleite any update on this one?

@jesseleite
Copy link
Member

@FrittenKeeZ Will dig into this one again soon 👍 I can't remember the reason, but leaving this issue open until we take another look.

Curious though, can you change the site handle from default to your preferred handle post-migration? Should be a relatively easy find-and-replace in your project I would think?

@FrittenKeeZ
Copy link
Author

@jesseleite yes I'm doing that during my testing, though it's easy to overlook various configurations and folders.

@FrittenKeeZ
Copy link
Author

FrittenKeeZ commented Nov 19, 2021

@jesseleite I just took a look at this, and since v3 works quite fine without using default it all comes down to convenience of migrating content. The files affecting the conversion to default are these:

trait Statamic\Migrator\Concerns\MigratesLocalizedContent
class Statamic\Migrator\GlobalSetMigrator
class Statamic\Migrator\PagesMigrator
class Statamic\Migrator\SettingsMigrator

Specifically it seems like you're using default for the base content, instead of dynamically pulling the first site's key instead, so it should be possible to use the original keys all the way through.
We'll be using this tool for 7 sites, 3 of which are multi-language setups, so it would be nice not having to do manual handling every time we test the migration.

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

No branches or pull requests

3 participants