-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(cordova/apple/ios): expand import_messages
action to generate iOS strings
#1683
Changes from all commits
228bfda
4d28271
6086320
700d00d
af3e22d
8883f0e
5c4a673
9d52de7
cc6edd7
1c1570a
b1eab9b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
// Copyright 2023 The Outline Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
import {readFile, writeFile} from 'fs/promises'; | ||
import path from 'path'; | ||
import XML from 'xmlbuilder2'; | ||
|
||
const STRINGS_DIR = ['src', 'cordova', 'plugin', 'android', 'resources', 'strings']; | ||
const STRINGS_FILENAME = 'strings.xml'; | ||
const XML_STRING_ID_PROPERTY = '@name'; | ||
const XML_TEXT_CONTENT = '#'; | ||
|
||
function escapeXmlCharacters(str) { | ||
return str | ||
.replace(/"/g, '\\"') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: we could probably get all of these in a single pass with reduce other nit: consider |
||
.replace(/'/g, "\\'") | ||
Comment on lines
+25
to
+27
Check failure Code scanning / CodeQL Incomplete string escaping or encoding
This does not escape backslash characters in the input.
|
||
.replace(/</g, '\\<') | ||
Comment on lines
+25
to
+28
Check failure Code scanning / CodeQL Incomplete string escaping or encoding
This does not escape backslash characters in the input.
|
||
.replace(/>/g, '\\>;') | ||
.replace(/&/g, '\\&'); | ||
Comment on lines
+25
to
+30
Check failure Code scanning / CodeQL Incomplete string escaping or encoding
This does not escape backslash characters in the input.
|
||
} | ||
|
||
function getNativeLocale(locale) { | ||
switch (locale) { | ||
case 'es-419': | ||
return 'es'; | ||
case 'sr-Latn': | ||
return 'b+sr+Latn'; | ||
default: | ||
return locale.replace('-', '-r'); | ||
} | ||
} | ||
|
||
/** | ||
* Retrieves a filepath for a given locale to read/write strings to. | ||
* @param {string} locale A locale for which to get a strings filepath. | ||
* @returns {string} The filepath. | ||
*/ | ||
export function getStringsFilepath(locale) { | ||
const localeSuffix = locale ? `-${getNativeLocale(locale)}` : ''; | ||
return path.join(...STRINGS_DIR, `values${localeSuffix}`, STRINGS_FILENAME); | ||
} | ||
|
||
/** | ||
* Reads messages that require translations. | ||
* @return {Map<string, string>} messages The messages to translate. | ||
*/ | ||
export async function readMessages() { | ||
const strings = await XML.create(await readFile(getStringsFilepath(), 'utf8')).end({format: 'object'}).resources | ||
.string; | ||
return strings.reduce((acc, string) => { | ||
return acc.set(string[XML_STRING_ID_PROPERTY], string[XML_TEXT_CONTENT]); | ||
}, new Map()); | ||
} | ||
|
||
/** | ||
* Writes output messages to a given path in the Android expected format. | ||
* @param {string} path The path to write the messages to. | ||
* @param {Map<string, string>} messages The messages to write. | ||
*/ | ||
export async function writeMessages(path, messages) { | ||
const output = Object.entries(messages).reduce((acc, [key, value]) => { | ||
acc.push({ | ||
[XML_STRING_ID_PROPERTY]: key, | ||
[XML_TEXT_CONTENT]: escapeXmlCharacters(value), | ||
}); | ||
return acc; | ||
}, []); | ||
|
||
await writeFile( | ||
path, | ||
XML.create({encoding: 'UTF-8'}, {resources: {string: output}}).end({prettyPrint: true, wellFormed: true}) | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ import PackageDescription | |
|
||
let package = Package( | ||
name: "OutlineAppleLib", | ||
defaultLocalization: "en", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice! |
||
products: [ | ||
.library( | ||
name: "OutlineAppleLib", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"connected_server_state" = "Gekoppel"; | ||
"disconnected_server_state" = "Ontkoppel"; | ||
"tray_open_window" = "Oop"; | ||
"quit" = "Verlaat"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"connected_server_state" = "ተገናኝቷል"; | ||
"disconnected_server_state" = "ተቋርጧል"; | ||
"tray_open_window" = "ክፈት"; | ||
"quit" = "ጨርስ"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"connected_server_state" = "متصل"; | ||
"disconnected_server_state" = "غير متصل"; | ||
"tray_open_window" = "فتح"; | ||
"quit" = "إنهاء"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"connected_server_state" = "Qoşuldu"; | ||
"disconnected_server_state" = "Bağlantı kəsildi"; | ||
"tray_open_window" = "Açın"; | ||
"quit" = "Çıxın"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"connected_server_state" = "Установена е връзка"; | ||
"disconnected_server_state" = "Връзката бе прекратена"; | ||
"tray_open_window" = "Отваряне"; | ||
"quit" = "Излизане"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"connected_server_state" = "কানেক্ট করা আছে"; | ||
"disconnected_server_state" = "ডিসকানেক্ট হয়ে গেছে"; | ||
"tray_open_window" = "খুলুন"; | ||
"quit" = "বেরিয়ে আসুন"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"connected_server_state" = "Povezano"; | ||
"disconnected_server_state" = "Veza je prekinuta"; | ||
"tray_open_window" = "Otvori"; | ||
"quit" = "Napusti"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"connected_server_state" = "Connectat"; | ||
"disconnected_server_state" = "Desconnectat"; | ||
"tray_open_window" = "Obre"; | ||
"quit" = "Surt"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"connected_server_state" = "Připojeno"; | ||
"disconnected_server_state" = "Odpojeno"; | ||
"tray_open_window" = "Otevřít"; | ||
"quit" = "Zavřít"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"connected_server_state" = "Tilsluttet"; | ||
"disconnected_server_state" = "Forbindelsen er afbrudt"; | ||
"tray_open_window" = "Åbn"; | ||
"quit" = "Luk"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"connected_server_state" = "Verbunden"; | ||
"disconnected_server_state" = "Nicht verbunden"; | ||
"tray_open_window" = "Öffnen"; | ||
"quit" = "Beenden"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"connected_server_state" = "Συνδεδεμένος"; | ||
"disconnected_server_state" = "Αποσυνδεδεμένος"; | ||
"tray_open_window" = "Άνοιγμα"; | ||
"quit" = "Έξοδος"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"connected_server_state" = "Connected"; | ||
"disconnected_server_state" = "Disconnected"; | ||
"tray_open_window" = "Open"; | ||
"quit" = "Exit"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"connected_server_state" = "Connected"; | ||
"disconnected_server_state" = "Disconnected"; | ||
"tray_open_window" = "Open"; | ||
"quit" = "Quit"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"connected_server_state" = "Conectado"; | ||
"disconnected_server_state" = "Desconectado"; | ||
"tray_open_window" = "Abrir"; | ||
"quit" = "Salir"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"connected_server_state" = "Conectado"; | ||
"disconnected_server_state" = "Desconectado"; | ||
"tray_open_window" = "Abrir"; | ||
"quit" = "Cerrar"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"connected_server_state" = "Ühendatud"; | ||
"disconnected_server_state" = "Ühendus on katkestatud"; | ||
"tray_open_window" = "Ava"; | ||
"quit" = "Välju"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"connected_server_state" = "وصل شدید"; | ||
"disconnected_server_state" = "اتصال قطع شد"; | ||
"tray_open_window" = "باز کردن"; | ||
"quit" = "خروج"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"connected_server_state" = "Yhdistetty"; | ||
"disconnected_server_state" = "Yhteys katkaistu"; | ||
"tray_open_window" = "Avaa"; | ||
"quit" = "Sulje"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"connected_server_state" = "Nakakonekta na"; | ||
"disconnected_server_state" = "Nadiskonekta"; | ||
"tray_open_window" = "Buksan"; | ||
"quit" = "Umalis"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"connected_server_state" = "Connecté"; | ||
"disconnected_server_state" = "Déconnecté"; | ||
"tray_open_window" = "Ouvrir"; | ||
"quit" = "Quitter"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"connected_server_state" = "מחובר"; | ||
"disconnected_server_state" = "מנותק"; | ||
"tray_open_window" = "פתיחה"; | ||
"quit" = "יציאה"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"connected_server_state" = "कनेक्ट किया गया"; | ||
"disconnected_server_state" = "डिसकनेक्ट किया गया"; | ||
"tray_open_window" = "खोलें"; | ||
"quit" = "छोड़ें"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"connected_server_state" = "Povezano"; | ||
"disconnected_server_state" = "Veza je prekinuta"; | ||
"tray_open_window" = "Otvori"; | ||
"quit" = "Zatvori"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"connected_server_state" = "Csatlakoztatva"; | ||
"disconnected_server_state" = "Leválasztva"; | ||
"tray_open_window" = "Megnyitás"; | ||
"quit" = "Kilépés"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"connected_server_state" = "Միացված է"; | ||
"disconnected_server_state" = "Անջատված է"; | ||
"tray_open_window" = "Բացել"; | ||
"quit" = "Փակել"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"connected_server_state" = "Terhubung"; | ||
"disconnected_server_state" = "Sambungan terputus"; | ||
"tray_open_window" = "Buka"; | ||
"quit" = "Tutup"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"connected_server_state" = "Tengt"; | ||
"disconnected_server_state" = "Aftengt"; | ||
"tray_open_window" = "Opna"; | ||
"quit" = "Hætta"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"connected_server_state" = "Connesso"; | ||
"disconnected_server_state" = "Server disconnesso"; | ||
"tray_open_window" = "Apri"; | ||
"quit" = "Esci"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"connected_server_state" = "接続しました"; | ||
"disconnected_server_state" = "接続が切断されました"; | ||
"tray_open_window" = "開く"; | ||
"quit" = "終了"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"connected_server_state" = "დაკავშირებულია"; | ||
"disconnected_server_state" = "კავშირი გაწყვეტილია"; | ||
"tray_open_window" = "ღიაა"; | ||
"quit" = "გასვლა"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"connected_server_state" = "Байланыс орнатылды."; | ||
"disconnected_server_state" = "Ажыратылған"; | ||
"tray_open_window" = "Ашу"; | ||
"quit" = "Шығу"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"connected_server_state" = "បានភ្ជាប់"; | ||
"disconnected_server_state" = "បានផ្ដាច់"; | ||
"tray_open_window" = "បើក"; | ||
"quit" = "ចាកចេញ"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"connected_server_state" = "연결됨"; | ||
"disconnected_server_state" = "연결 해제됨"; | ||
"tray_open_window" = "열기"; | ||
"quit" = "종료"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"connected_server_state" = "ເຊື່ອມຕໍ່ແລ້ວ"; | ||
"disconnected_server_state" = "ຕັດການເຊື່ອມຕໍ່ແລ້ວ"; | ||
"tray_open_window" = "ເປີດ"; | ||
"quit" = "ປິດ"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"connected_server_state" = "Prisijungta"; | ||
"disconnected_server_state" = "Atsijungta"; | ||
"tray_open_window" = "Atidaryti"; | ||
"quit" = "Išeiti"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"connected_server_state" = "Savienojums izveidots"; | ||
"disconnected_server_state" = "Savienojums pārtraukts"; | ||
"tray_open_window" = "Atvērt"; | ||
"quit" = "Aizvērt"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"connected_server_state" = "Поврзано"; | ||
"disconnected_server_state" = "Не е поврзано"; | ||
"tray_open_window" = "Отвори"; | ||
"quit" = "Излези"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"connected_server_state" = "Холбогдсон"; | ||
"disconnected_server_state" = "Салсан"; | ||
"tray_open_window" = "Нээх"; | ||
"quit" = "Гарах"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"connected_server_state" = "कनेक्ट केले आहे"; | ||
"disconnected_server_state" = "डिस्कनेक्ट केले"; | ||
"tray_open_window" = "उघडा"; | ||
"quit" = "बाहेर पडा"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"connected_server_state" = "Disambungkan"; | ||
"disconnected_server_state" = "Diputuskan sambungan"; | ||
"tray_open_window" = "Buka"; | ||
"quit" = "Keluar"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"connected_server_state" = "ချိတ်ဆက်ထားသည်"; | ||
"disconnected_server_state" = "ချိတ်ဆက်မထားပါ"; | ||
"tray_open_window" = "ဖွင့်ရန်"; | ||
"quit" = "ထွက်ရန်"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"connected_server_state" = "कनेक्ट गरिएको छ"; | ||
"disconnected_server_state" = "डिस्कनेक्ट गरिएको छ"; | ||
"tray_open_window" = "खोल्नुहोस्"; | ||
"quit" = "बाहिरिनुहोस्"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"connected_server_state" = "Verbonden"; | ||
"disconnected_server_state" = "Verbinding verbroken"; | ||
"tray_open_window" = "Openen"; | ||
"quit" = "Sluiten"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"connected_server_state" = "Tilkoblet"; | ||
"disconnected_server_state" = "Koblet fra"; | ||
"tray_open_window" = "Åpne"; | ||
"quit" = "Avslutt"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"connected_server_state" = "Połączono"; | ||
"disconnected_server_state" = "Odłączono"; | ||
"tray_open_window" = "Otwórz"; | ||
"quit" = "Zamknij"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"connected_server_state" = "Conectado"; | ||
"disconnected_server_state" = "Desconectado"; | ||
"tray_open_window" = "Abrir"; | ||
"quit" = "Sair"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"connected_server_state" = "Ligado"; | ||
"disconnected_server_state" = "Desligado"; | ||
"tray_open_window" = "Abrir"; | ||
"quit" = "Sair"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"connected_server_state" = "Conectat"; | ||
"disconnected_server_state" = "Deconectat"; | ||
"tray_open_window" = "Deschideți"; | ||
"quit" = "Ieșiți"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"connected_server_state" = "Подключен"; | ||
"disconnected_server_state" = "Отключен"; | ||
"tray_open_window" = "Открыть"; | ||
"quit" = "Выйти"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"connected_server_state" = "සම්බන්ධයි"; | ||
"disconnected_server_state" = "විසන්ධි විය"; | ||
"tray_open_window" = "විවෘතයි"; | ||
"quit" = "ඉවත් වන්න"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"connected_server_state" = "Pripojené"; | ||
"disconnected_server_state" = "Odpojené"; | ||
"tray_open_window" = "Otvoriť"; | ||
"quit" = "Ukončiť"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"connected_server_state" = "Povezava je vzpostavljena"; | ||
"disconnected_server_state" = "Povezava je prekinjena"; | ||
"tray_open_window" = "Odpri"; | ||
"quit" = "Zapri"; |
Check failure
Code scanning / CodeQL
Incomplete string escaping or encoding