Skip to content

Commit

Permalink
docs: add descriptive text for suggested query aria label (#3039)
Browse files Browse the repository at this point in the history
* add explanatory text for query suggestion label

https://coveord.atlassian.net/browse/KIT-2590

* prep locales for translate script

https://coveord.atlassian.net/browse/KIT-2590

* add translations for recent query

https://coveord.atlassian.net/browse/KIT-2590

* add missing locale entries for between parans

https://coveord.atlassian.net/browse/KIT-2590

* add info msg before fetching from API

https://coveord.atlassian.net/browse/KIT-2590

* remove extra space in generated locale

https://coveord.atlassian.net/browse/KIT-2590

* prep locale to regen between parentheses

https://coveord.atlassian.net/browse/KIT-2590

* Revert "prep locale to regen between parentheses"

This reverts commit 0db6837.

* replace abnormal parens for zh

https://coveord.atlassian.net/browse/KIT-2590

* add eol when writing locales file

https://coveord.atlassian.net/browse/KIT-2590

* fix validation script to use the return value from gpt

https://coveord.atlassian.net/browse/KIT-2590

* fix prompt to return correct validation result

https://coveord.atlassian.net/browse/KIT-2590

* add option to validate only selected given keys

https://coveord.atlassian.net/browse/KIT-2590

* move translation gpt scripts under scripts dir

https://coveord.atlassian.net/browse/KIT-2590

* replace EOL with \n

https://coveord.atlassian.net/browse/KIT-2590
  • Loading branch information
mrrajamanickam-coveo authored Aug 18, 2023
1 parent 8fcd1ed commit 61d849b
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ reports/*.xml
sarifs
**.cy.ts.mp4
.cspellcache
utils/translation-gpt/temporary.json
scripts/translation-gpt/temporary.json

# CI Release
topology.json
Expand Down
76 changes: 48 additions & 28 deletions packages/atomic/src/locales.json
Original file line number Diff line number Diff line change
Expand Up @@ -405,31 +405,31 @@
"zh-tw": "輸入至少{{length}}個字元的查詢以啟用搜尋。"
},
"query-suggestion-label": {
"en": "“{{query}}”",
"fr": "« {{text}} »",
"cs": "„{{query}}“",
"da": "{{query}}",
"de": "„{{query}}“",
"el": "«{{query}}»",
"es": "{{query}}",
"fi": "”{{query}}”",
"hu": "„{{query}}”",
"id": "“{{query}}”",
"it": "{{query}}",
"ja": "「{{query}}」",
"ko": "{{query}}",
"nl": "{{query}}",
"no": "«{{query}}»",
"pl": "„{{query}}",
"pt": "“{{query}}”",
"pt-br": "{{query}}",
"ru": "«{{query}}»",
"sv": "”{{query}}”",
"th": "{{query}}",
"tr": "{{query}}",
"zh": "“{{query}}”",
"zh-cn": "“{{query}}”",
"zh-tw": "「{{query}}」"
"en": "“{{query}}”, suggested query",
"fr": "Requête suggérée pour « {{query}} »",
"cs": "Navržený dotaz pro „{{query}}“",
"da": "Foreslået søgning for «{{query}}»",
"de": "Vorgeschlagene Abfrage für „{{query}}“",
"el": "Προτεινόμενο αίτημα για τη «{{query}}»",
"es": "Consulta suggerida para «{{query}}»",
"fi": "Ehdotettu haku termille ”{{query}}”",
"hu": "Javasolt lekérdezés erre: „{{query}}”",
"id": "Permintaan yang disarankan untuk “{{query}}”",
"it": "Richiesta suggerita per \"{{query}}\"",
"ja": "「{{query}}」の提案されたクエリ",
"ko": "{{query}}’ 추천 검색어",
"nl": "Voorgestelde zoekopdracht voor '{{query}}'",
"no": "Foreslått søk for «{{query}}»",
"pl": "Zapropowane zapytanie dla „{{query}}",
"pt": "Consulta sugerida para “{{query}}”",
"pt-br": "Consulta sugerida para '{{query}}'",
"ru": "Рекомендуемый запрос для «{{query}}»",
"sv": "Föreslagen sökning för ”{{query}}”",
"th": "คำค้นที่แนะนำสำหรับ '{{query}}'",
"tr": "Önerilen sorgu için \"{{query}}\"",
"zh": "推荐的搜索查询:“{{query}}”",
"zh-cn": "“{{query}}”的建议查询",
"zh-tw": "建議查詢:「{{query}}」"
},
"recent-query-suggestion-label": {
"en": "“{{query}}”, recent query",
Expand Down Expand Up @@ -4431,9 +4431,29 @@
"between-parentheses": {
"en": "({{text}})",
"fr": "({{text}})",
"zh-cn": "({{text}})",
"zh": "({{text}})",
"zh-tw": "({{text}})"
"cs": "({{text}})",
"da": "({{text}})",
"de": "({{text}})",
"el": "({{text}})",
"es": "({{text}})",
"fi": "({{text}})",
"hu": "({{text}})",
"id": "({{text}})",
"it": "({{text}})",
"ja": "({{text}})",
"ko": "({{text}})",
"nl": "({{text}})",
"no": "({{text}})",
"pl": "({{text}})",
"pt": "({{text}})",
"pt-br": "({{text}})",
"ru": "({{text}})",
"sv": "({{text}})",
"th": "({{text}})",
"tr": "({{text}})",
"zh-cn": "({{text}})",
"zh": "({{text}})",
"zh-tw": "({{text}})"
},
"notifications": {
"en": "Notifications",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ You must set both of the following environment variables:

## translate.mjs

To run this script, navigate to `./utils/translation-gpt` and use the command `node translate.mjs`.
To run this script, navigate to `./scripts/translation-gpt` and use the command `node translate.mjs`.

While executing the script, a `temporary.json` file will be generated. Do not delete this file while the translation task is ongoing.

Expand All @@ -27,7 +27,11 @@ If there are a lot of translations that need to be performed, the script could t

## validate.mjs

To run this script, navigate to `./utils/translation-gpt` and use the command `node validate.mjs`.
To run this script, navigate to `./scripts/translation-gpt` and use the command `node validate.mjs`.

- This will validate all entries in the `locales.json` file.
- To validate only selected entries (e.g. recent additions) pass them as space seperated command line arguments
e.g. `node validate.mjs query-suggestion-label between-parentheses`

While executing the script, a `temporary.json` file will be generated. Do not delete this file while the validation task is ongoing.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ async function main() {
continue;
}

console.log(
`${translationKey}: Fetching translation for ${languagesThatNeedTranslation.length} languages from API.`
);

try {
const res = await fetch(env.COVEO_AZURE_OPEN_AI_ENDPOINT, {
method: 'POST',
Expand Down Expand Up @@ -123,7 +127,7 @@ async function main() {

writeFileSync(
'../../packages/atomic/src/locales.json',
readFileSync('temporary.json')
readFileSync('temporary.json') + '\n'
);
writeFileSync('temporary.json', JSON.stringify({}, null, 2));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import {readFileSync, writeFileSync} from 'fs';
import {existsSync, readFileSync, writeFileSync} from 'fs';
import {env} from 'process';

const keysToValidate = process.argv.slice(2);

const fileToValidate = JSON.parse(
readFileSync('../../packages/atomic/src/locales.json')
);
Expand All @@ -23,10 +25,8 @@ const prompt = (translations) =>
Give me the answer back in JSON format where each key is the language code, and each value is an object with two property: "translation" and "validation".
"translation" Should be the translated string in english.
"validation" should contain exactly and only true if the meaning of the "translation" is similar to the "validator" property.
Otherwise, "validation" should contain an explanation about why it is not similar or why the meaning is different.
If the meaning of the "translation" is similar to the "validator" property "validation" should contain exactly and only true. Else it should contain an explanation on why "validator" is different from the "translation".
The JSON object is:
${JSON.stringify(translations, null, 2)}
Expand All @@ -36,6 +36,8 @@ async function main() {
let allIdentifiedProblems = {};

for (const translationKey of Object.keys(fileToValidate)) {
if (keysToValidate.length > 0 && !keysToValidate.includes(translationKey))
continue;
try {
const englishTranslation = fileToValidate[translationKey]['en'];
const translationsToValidate = fileToValidate[translationKey];
Expand Down Expand Up @@ -66,7 +68,7 @@ async function main() {

Object.entries(answer).forEach(
([languageCode, {validation, translation}]) => {
if (true) {
if (validation !== true) {
const problem = {
languageCode,
translation,
Expand Down

0 comments on commit 61d849b

Please sign in to comment.