Skip to content
This repository has been archived by the owner on May 10, 2023. It is now read-only.

Commit

Permalink
fix: migrate ne to ne-NP
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelKohler committed Jun 26, 2021
1 parent 07d6e66 commit 26092df
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
1 change: 0 additions & 1 deletion scripts/exporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
};

Expand Down
7 changes: 6 additions & 1 deletion server/lib/languages.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const FALLBACK_LOCALE = 'en';

const LANGUAGE_MAPPING = {
// CV - Sentence Collector
'ne-NP': 'ne',
'pa-IN': 'pa',
};

Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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());
Expand Down
12 changes: 12 additions & 0 deletions server/migrations/20210626134800-migrate-ne-to-ne-NP.js
Original file line number Diff line number Diff line change
@@ -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(),
};
11 changes: 11 additions & 0 deletions server/migrations/20210626134830-migrate-np-users.js
Original file line number Diff line number Diff line change
@@ -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(),
};

0 comments on commit 26092df

Please sign in to comment.