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

Added back-migration for Big Locale Refactoring #14062

Conversation

uberbrady
Copy link
Collaborator

Just in case something goes horribly wrong with an upgrade to v6.3.0 (or wherever we land this Giant Locale Change), I thought it best for us to have a back migration.

This change pulls the giant Language Array out into a $language_map static variable, so it can continue to be used by the existing mapLegacyLocale static Helper method, as well as the new mapBackToLegacyLocale static Helper method. I could have done some kind of clever loading up another array with smart keys-and-values, but this is probably only going to ever be used in the back-migration, and nowhere else. So hopefully not used much at all. Because of that, I left it unoptimized.

I tested by looking at my users and my settings record, then running the migration, checking those tables again, then migrating back, and checking those tables again. And they seem like they look kinda how you'd expect.

Copy link

what-the-diff bot commented Dec 19, 2023

PR Summary

  • Introduction of a New Static Property
    A new static property named $language_map has been included in the Helper.php file located under app/Helpers. This property, essentially an array, stores the associations between language codes and their corresponding locales.

  • Revamp of mapLegacyLocale Method
    The mapLegacyLocale method in the Helper.php file has been updated. It no longer uses the previously defined $languages array manually, rather it relies on the recently added $language_map static property to link the obsolete language code to its appropriate locale.

  • New Method Inclusion: mapBackToLegacyLocale
    A fresh method named mapBackToLegacyLocale has been embedded in the Helper.php file. This function takes advantage of the $language_map static property to map an updated locale back to its corresponding obsolete language code.

  • Refactoring of the up Method
    The up method embedded in the 2023_12_19_081112_fix_language_dirs.php migration has been overhauled. Its responsibility is to update the settings and users tables. The existing locale values are transformed into their equivalent obsolete language codes using the mapBackToLegacyLocale method from the Helper.php file.

@snipe snipe merged commit de62e27 into snipe:localizations/new_strings_pre-6.3.0 Dec 19, 2023
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants