From 26092dff4cb1592fc137fbe5360e79cea392b828 Mon Sep 17 00:00:00 2001 From: Michael Kohler Date: Sat, 26 Jun 2021 13:08:48 +0000 Subject: [PATCH] fix: migrate ne to ne-NP --- scripts/exporter.js | 1 - server/lib/languages.js | 7 ++++++- .../migrations/20210626134800-migrate-ne-to-ne-NP.js | 12 ++++++++++++ server/migrations/20210626134830-migrate-np-users.js | 11 +++++++++++ 4 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 server/migrations/20210626134800-migrate-ne-to-ne-NP.js create mode 100644 server/migrations/20210626134830-migrate-np-users.js diff --git a/scripts/exporter.js b/scripts/exporter.js index e2d375eb..5f92c660 100644 --- a/scripts/exporter.js +++ b/scripts/exporter.js @@ -14,7 +14,6 @@ const OUTPUT_TXT = 'sentence-collector.txt'; // Mapping from PONTOON locale -> SC locale code const LANGUAGE_MAPPING = { - 'ne-NP': 'ne', 'pa-IN': 'pa', }; diff --git a/server/lib/languages.js b/server/lib/languages.js index adec25dc..99c774f9 100644 --- a/server/lib/languages.js +++ b/server/lib/languages.js @@ -4,7 +4,6 @@ const FALLBACK_LOCALE = 'en'; const LANGUAGE_MAPPING = { // CV - Sentence Collector - 'ne-NP': 'ne', 'pa-IN': 'pa', }; @@ -145,6 +144,11 @@ const ADDITIONAL_LANGUAGES = [ name: 'Erzya', nativeName: 'эрзянь кель', }, + { + id: 'ne-NP', + name: 'Nepali', + nativeName: 'नेपाली', + }, { // https://github.com/common-voice/common-voice/issues/3160 id: 'nia', name: 'Nias', @@ -252,6 +256,7 @@ const LANGUAGES_TO_REMOVE = [ 'ff', // re-added - https://discourse.mozilla.org/t/fulah-language-naming-consistency/78378 'ga', // covered by ga-IE 'sv', // covered by sv-SE + 'ne', // covered by ne-NP ]; const isoLanguages = ISO6391.getLanguages(ISO6391.getAllCodes()); diff --git a/server/migrations/20210626134800-migrate-ne-to-ne-NP.js b/server/migrations/20210626134800-migrate-ne-to-ne-NP.js new file mode 100644 index 00000000..992ed248 --- /dev/null +++ b/server/migrations/20210626134800-migrate-ne-to-ne-NP.js @@ -0,0 +1,12 @@ +'use strict'; + +module.exports = { + up: (queryInterface) => { + return queryInterface.sequelize.query(` + UPDATE Sentences + SET localeId="ne-NP" + WHERE localeId="ne" + `); + }, + down: () => Promise.resolve(), +}; diff --git a/server/migrations/20210626134830-migrate-np-users.js b/server/migrations/20210626134830-migrate-np-users.js new file mode 100644 index 00000000..ad9fc602 --- /dev/null +++ b/server/migrations/20210626134830-migrate-np-users.js @@ -0,0 +1,11 @@ +'use strict'; + +module.exports = { + up: async (queryInterface) => { + await queryInterface.sequelize.query("UPDATE Users SET languages = REPLACE(languages, 'ne', 'ne-NP') WHERE languages='ne'"); + await queryInterface.sequelize.query("UPDATE Users SET languages = REPLACE(languages, 'ne,', 'ne-NP,') WHERE languages LIKE 'ne,%'"); + await queryInterface.sequelize.query("UPDATE Users SET languages = REPLACE(languages, ',ne,', ',ne-NP,') WHERE languages LIKE '%,ne,%'"); + await queryInterface.sequelize.query("UPDATE Users SET languages = REPLACE(languages, ',ne', ',ne-NP') WHERE languages LIKE '%,ne'"); + }, + down: () => Promise.resolve(), +};