Skip to content

Commit

Permalink
Merge pull request #668 from unfoldingWord/merge-release-v2.4.1
Browse files Browse the repository at this point in the history
Merge release v2.4.1
  • Loading branch information
PhotoNomad0 authored Aug 27, 2024
2 parents c07f415 + 2fdee9d commit 8199af4
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 19 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gateway-edit",
"version": "2.4.0",
"version": "2.4.1",
"engines": {
"node": ">=18.18.0"
},
Expand Down Expand Up @@ -54,15 +54,15 @@
"react-icons": "^4.8.0",
"regenerator-runtime": "^0.13.7",
"resource-workspace-rcl": "2.1.4",
"scripture-resources-rcl": "5.5.12",
"scripture-resources-rcl": "5.5.13",
"scripture-tsv": "1.2.0",
"single-scripture-rcl": "3.4.23",
"tailwindcss": "^2.0.4",
"tc-ui-toolkit": "5.3.3",
"translation-helps-rcl": "3.6.3",
"use-deep-compare-effect": "^1.3.1",
"word-aligner": "^1.0.0",
"word-aligner-rcl": "1.1.2"
"word-aligner-rcl": "1.1.3"
},
"devDependencies": {
"@cypress/code-coverage": "^3.9.11",
Expand Down
99 changes: 99 additions & 0 deletions src/common/__tests__/languages.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/* eslint-env jest */
import * as Languages from '../languages';

describe('Test Languages',()=>{
const minimumLangCount = 9000;

test('getLanguage() should work with mixed and lower case', () => {
const codes = ['sr-latn', 'sr-Latn', 'SR-LATN', 'ur-deva', 'ur-Deva', 'UR-DEVA', 'ZH'];

for (let languageId of codes) {
const languageData = Languages.getLanguage({languageId});
expect(languageData).toBeTruthy();
expect(languageData.languageId.toLowerCase()).toEqual(languageId.toLowerCase());
}
});

test('getLanguages() should work', () => {
const languages = Languages.getLanguages();
const langCount = languages.length;
expect(langCount).toBeLessThan(minimumLangCount * 1.2);

// make sure fields are valid and in sequence
for (let i = 1; i < langCount; i++) {
const lang = languages[i - 1];
expect(lang.languageId.length).toBeGreaterThan(0);
const languageName = lang.languageName || lang.localized
if (!languageName.length) {
console.log(`invalid languageName ${languageName} for languageId ${lang.languageId}`)
}
expect(lang.localized.length).toBeGreaterThan(0);
if (!lang.localized.length) {
console.log(`invalid localized ${lang.localized} for languageId ${lang.languageId}`)
}
expect(lang.localized.length).toBeGreaterThan(0);
const directionValid = lang.direction === 'ltr' || lang.direction === 'rtl'
if (!lang.localized.length) {
console.log(`invalid direction ${lang.direction} for languageId ${lang.languageId}`)
}
expect(directionValid).toBeTruthy();
}
});

test('getLanguages() verify no dupes among language codes.', () => {
let languages = Languages.getLanguages();
let localLanguageCodes = languages.map(language => language.languageId);

const sorted = localLanguageCodes.sort();
let dupsFound = 0;

for ( let idx = 1; idx < sorted.length; idx++ ) {
if ( sorted[idx] == sorted[idx-1]) {
dupsFound++;
}
}

expect(dupsFound).toBeLessThan(1);
expect(sorted.length).toBeGreaterThan(minimumLangCount);
});

test('getGatewayLanguages() verify no dupes among language codes.', async () => {
let languages = await Languages.getGatewayLanguages();
let localLanguageCodes = languages.map(language => language.languageId);

const sorted = localLanguageCodes.sort();
let dupsFound = 0;

for ( let idx = 1; idx < sorted.length; idx++ ) {
if ( sorted[idx] == sorted[idx-1]) {
dupsFound++;
}
}

expect(dupsFound).toBeLessThan(1);
const minimumGwLangs = 40;
const maximumGwLangs = 100;
expect(sorted.length).toBeGreaterThan(minimumGwLangs);
expect(sorted.length).not.toBeGreaterThan(maximumGwLangs);
});

describe('getLanguage()',()=>{
test('Nepali ne should succeed', () => {
const code = 'ne';
const name = 'Nepali';
let foundLanguage = Languages.getLanguage({ languageId: code });

expect(foundLanguage.languageName).toEqual(name);
expect(foundLanguage.languageId).toEqual(code);
});

test('Nepali npi should succeed', () => {
const code = 'npi';
const name = 'Nepali';
let foundLanguage = Languages.getLanguage({ languageId: code });

expect(foundLanguage.languageName).toEqual(name);
expect(foundLanguage.languageId).toEqual(code);
});
});
});
5 changes: 4 additions & 1 deletion src/common/languages.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import languagesJSON from './languages.json'

export const getLanguage = ({ languageId }) => {
let _language
const language = languagesJSON.filter(object => object.lc === languageId)[0]
languageId = languageId.toLowerCase()
const language = languagesJSON.find(object => {
return object.lc?.toLowerCase() === languageId // compare lower case
})
_language = formatLanguage({ language })
return _language
}
Expand Down
2 changes: 1 addition & 1 deletion src/common/languages.json

Large diffs are not rendered by default.

28 changes: 14 additions & 14 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9425,10 +9425,10 @@ schema-utils@^3.0.0:
ajv "^6.12.5"
ajv-keywords "^3.5.2"

[email protected].12:
version "5.5.12"
resolved "https://registry.yarnpkg.com/scripture-resources-rcl/-/scripture-resources-rcl-5.5.12.tgz#789c89ec02ba5cd94c6688d4cc5cccfcee58a81d"
integrity sha512-/+0cTeU/gWUNTDqmM0/gZIf4T2h1mj3FE8whdYbITT9N4F7pQhmugHZmS25lbJVw99LGf00g+nH3Wi5UsPTY2w==
[email protected].13:
version "5.5.13"
resolved "https://registry.yarnpkg.com/scripture-resources-rcl/-/scripture-resources-rcl-5.5.13.tgz#48313f0923f62c8656b0463bfb796c720761a331"
integrity sha512-lCmwDWOsFC/gf02YINm18hrYnb5H47AoStrpY8DBd6PVTywSW3khjwO8IkbguCQHmZOVciRiUt29E26Xx1UQFg==
dependencies:
bible-reference-range "^1.1.0"
deep-freeze "^0.0.1"
Expand All @@ -9442,7 +9442,7 @@ [email protected]:
string-punctuation-tokenizer "^2.2.0"
tc-ui-toolkit "^5.3.3"
use-deep-compare-effect "^1.3.1"
usfm-js "^3.4.2"
usfm-js "^3.4.3"
uw-quote-helpers "1.1.4"
word-aligner "^1.0.0"
xregexp "^4.1.1"
Expand Down Expand Up @@ -10783,10 +10783,10 @@ use@^3.1.0:
resolved "https://registry.yarnpkg.com/use/-/use-3.1.1.tgz#d50c8cac79a19fbc20f2911f56eb973f4e10070f"
integrity sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ==

[email protected].2, usfm-js@^3.4.2:
version "3.4.2"
resolved "https://registry.yarnpkg.com/usfm-js/-/usfm-js-3.4.2.tgz#a4232cffe38c9f521246b007a4045648cbcf419a"
integrity sha512-i5nGxGwFhkOWd7xgfVWQ6GTkCpksfy5AUIwNJcwanTn3ua5J1nwl3pjApCDA6x1B++8ICkcQMUt0FB/bkKdE2g==
[email protected].3, usfm-js@^3.4.3:
version "3.4.3"
resolved "https://registry.yarnpkg.com/usfm-js/-/usfm-js-3.4.3.tgz#dffa5a00cdbf7c02df89f6e876136df6aa532361"
integrity sha512-c5d2dzmSnEfFSPfMXnnycIPwdw8ryBsb2r2CUEwiXpsUMm+gDmhFz5GGOufYP5rGGVwAssHdSM8oOkcaHz+Hwg==
dependencies:
lodash.clonedeep "^4.5.0"

Expand Down Expand Up @@ -11101,17 +11101,17 @@ which@^2.0.1:
dependencies:
isexe "^2.0.0"

[email protected].2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/word-aligner-rcl/-/word-aligner-rcl-1.1.2.tgz#6bda84e580be9a58cc24f96892743a35c53b4713"
integrity sha512-2GGIFmMpBY8lpidSwC7MTXkZOl/xNomI9ixCOPIRaVPXASlUNM/+GPIR23D5CgqirXqGXs/4ZUhs+y9RihaInw==
[email protected].3:
version "1.1.3"
resolved "https://registry.yarnpkg.com/word-aligner-rcl/-/word-aligner-rcl-1.1.3.tgz#4d24a102b13f6770086cb042c1c90c825d93edb8"
integrity sha512-glVSJ75rX254R+0vLjhyZQ51ns8QBb4YKgYd46yTjpUXASlPRcykOQKzVXdOFeE2fEz6t6Gu1nKWrDL+EvwUsw==
dependencies:
bible-reference-range "^1.1.0"
deep-equal "^2.0.5"
file-loader "^6.2.0"
lodash.clonedeep "^4.5.0"
string-punctuation-tokenizer "2.2.0"
usfm-js "3.4.2"
usfm-js "3.4.3"
word-aligner "1.0.2"
wordmap-lexer "^0.3.6"

Expand Down

0 comments on commit 8199af4

Please sign in to comment.