discourse-translator/db/migrate
Natalie Tay 644a165818
DEV: Hyphenate locales (#206)
Currently (before the custom fields to tables migrations), locales are sometimes saved as "pt-PT" and "pt_BR" due to the API returning the former and us saving the latter through I18n.locale.

e.g. we are seeing the following in the custom fields, which would mean that the table migrations (https://github.com/discourse/discourse-translator/pull/201) also have inherited the discrepancies.

```
#<PostCustomField:0x00007faffb49f798
 id: 12321231,
 post_id: 1231241,
 name: "translated_text",
 value: "{\"en_GB\":\"\\u003cp\\u003eGreat post my friend \\u00...",  # < locale is underscored
...>

# and

#<PostCustomField:0x00007faffb49dfd8
 id: 12313123,
 post_id: 123123,
 name: "post_detected_lang",
 value: "pt-PT", # < locale is hyphenated
 ...>
```

This commit adds a migration to convert all values to the hyphenated version, ensures we save the hyphenated ones to the db, and introduces a `locale_matches?` on the translatable models.
2025-02-11 16:04:22 +08:00
..
20210429154318_remove_empty_translation_custom_fields.rb DEV: Promote historic post_deploy migrations (#91) 2022-12-19 17:27:43 +02:00
20230323110557_rename_translator_azure_custom_domain_site_setting.rb DEV: Rename translator_azure_custom_domain Site Setting (#102) 2023-04-17 14:07:23 +00:00
20250205082400_create_translation_tables.rb DEV: Move translation custom fields into their own tables (#201) 2025-02-10 12:29:07 +08:00
20250205082401_move_translations_custom_fields_to_table.rb DEV: Move translation custom fields into their own tables (#201) 2025-02-10 12:29:07 +08:00
20250205082402_create_translation_indexes.rb DEV: Move translation custom fields into their own tables (#201) 2025-02-10 12:29:07 +08:00
20250210171147_hyphenate_translator_locales.rb DEV: Hyphenate locales (#206) 2025-02-11 16:04:22 +08:00