mirror of
https://github.com/Foundry376/Mailspring.git
synced 2026-01-06 08:56:09 +08:00
Make the find-strings script prune localizations and give an overview of completeness
This commit is contained in:
parent
897e6361cb
commit
b38afe5e3f
2 changed files with 39 additions and 178 deletions
|
|
@ -1,170 +0,0 @@
|
|||
{
|
||||
"(No Recipients)": "(Nenhum destinatário)",
|
||||
"(No Subject)": "(sem assunto)",
|
||||
"Accept": "Aceitar",
|
||||
"Accounts": "Contas",
|
||||
"Actions": "Ações",
|
||||
"Activity": "Atividade",
|
||||
"Add Account": "Adicionar conta",
|
||||
"Address": "Contactos",
|
||||
"All": "todas as",
|
||||
"All Accounts": "Todas as contas",
|
||||
"Any": "Qualquer",
|
||||
"Application": "Aplicação",
|
||||
"Apply Label": "etiquetar",
|
||||
"Archive": "Arquivar",
|
||||
"Attachments": "Anexos",
|
||||
"Back": "Anterior",
|
||||
"Body": "Corpo",
|
||||
"Bring All to Front": "Passar tudo para a frente",
|
||||
"Cancel": "Cancelar",
|
||||
"Cannot send message": "Não é possível enviar a mensagem",
|
||||
"Checking": "A verificar",
|
||||
"Choose": "Selecionar",
|
||||
"Choose an image": "Selecione uma imagem",
|
||||
"Close Window": "Fechar janela",
|
||||
"Collapse All": "Comprimir tudo",
|
||||
"Compose New Message": "Criar nova mensagem",
|
||||
"Compose new message": "Criar uma mensagem nova.",
|
||||
"Composer": "Compositor",
|
||||
"Continue": "Continuar",
|
||||
"Copy": "Copiar",
|
||||
"Copy Image": "Copiar imagem",
|
||||
"Create": "Criar",
|
||||
"Custom": "Personalizado",
|
||||
"Custom Image…": "Imagem personalizada…",
|
||||
"Cut": "Cortar",
|
||||
"Date": "Data",
|
||||
"Decline": "Recusar",
|
||||
"Default": "Predefinição",
|
||||
"Delete": "Apagar",
|
||||
"Delete Template?": "Apagar modelo?",
|
||||
"Dismiss": "Fechar",
|
||||
"Don’t show this again": "Não voltar a mostrar esta mensagem",
|
||||
"Edit": "Edição",
|
||||
"Edit Message": "Editar mensagem",
|
||||
"Email": "E‑mail",
|
||||
"Empty": "Vazia",
|
||||
"Enable": "Ativar",
|
||||
"Enter Full Screen": "Ecrã completo",
|
||||
"Error": "Erro",
|
||||
"Event": "Evento",
|
||||
"Exit": "Sair",
|
||||
"Expand All": "Expandir tudo",
|
||||
"File": "Ficheiro",
|
||||
"Find": "Procurar",
|
||||
"Find Next": "Procurar seguinte",
|
||||
"Find Previous": "Procurar anterior",
|
||||
"Flags": "Assinaladas",
|
||||
"Folder": "Pasta",
|
||||
"Folders": "Pastas",
|
||||
"Forward": "Reencaminhar",
|
||||
"Forwarded Message": "Mensagem reencaminhada",
|
||||
"From": "De",
|
||||
"General": "Geral",
|
||||
"Get Started": "Introdução",
|
||||
"Go Back": "Anterior",
|
||||
"Go to %@": "Ir para %@",
|
||||
"Help": "Ajuda",
|
||||
"Hide": "Ocultar",
|
||||
"Hide Others": "Ocultar outras aplicações",
|
||||
"Hide Sidebar": "Ocultar barra lateral",
|
||||
"Inbox": "Recebido",
|
||||
"Indent": "Indentar",
|
||||
"Insert Numbered List": "Inserir lista numerada",
|
||||
"Insert a bulleted list": "Inserir uma lista com marcas.",
|
||||
"Install": "Instalar",
|
||||
"Job Title": "Cargo",
|
||||
"Labels": "Etiquetas",
|
||||
"Large": "Grande",
|
||||
"Layout": "Disposição",
|
||||
"Learn More": "Saiba mais",
|
||||
"Learn Spelling": "Aprender ortografia",
|
||||
"Look Up “%@”": "Procurar “%@”",
|
||||
"Manually": "manualmente",
|
||||
"Mark as Read": "Marcar como lida",
|
||||
"Market Cap": "Cap. bolsista",
|
||||
"Maybe": "Talvez",
|
||||
"Message": "Mensagem",
|
||||
"Message Sent Sound": "Som de mensagem enviada",
|
||||
"Minimize": "Minimizar",
|
||||
"Move Message": "Mover mensagem",
|
||||
"Moved to %@": "Passou para %@",
|
||||
"Name": "Nome",
|
||||
"Nature": "Natureza",
|
||||
"New Message": "Nova mensagem",
|
||||
"Next": "Seguinte",
|
||||
"No": "Não",
|
||||
"No Guesses Found": "Não foi encontrada nenhuma sugestão",
|
||||
"None": "Nenhuma",
|
||||
"Not Now": "Agora não",
|
||||
"Notifications": "Notificações",
|
||||
"Objects": "Objetos",
|
||||
"Offline": "Sem ligação",
|
||||
"Open": "Abrir",
|
||||
"Open Link": "Abrir hiperligação",
|
||||
"Outdent": "remover indentação",
|
||||
"Password": "Palavra‑passe",
|
||||
"Paste": "Colar",
|
||||
"Paste and Match Style": "Colar e manter estilo",
|
||||
"People": "Pessoas",
|
||||
"Phone": "Telefone",
|
||||
"Preview": "Pré-visualizar",
|
||||
"Print": "Imprimir",
|
||||
"Quit": "Sair",
|
||||
"Raw Source": "Código",
|
||||
"Read": "Lida",
|
||||
"Rebuild": "Reconstruir",
|
||||
"Redo": "Refazer",
|
||||
"Reminder": "Lembrete",
|
||||
"Reminders": "Lembretes",
|
||||
"Remove": "Remover",
|
||||
"Rename": "Alterar",
|
||||
"Reply": "Responder",
|
||||
"Reply All": "Responder a todos",
|
||||
"Reset": "Repor",
|
||||
"Search": "Pesquisar",
|
||||
"Search Results": "Resultados da pesquisa",
|
||||
"Search all mailboxes": "Pesquisar todas as caixas de correio",
|
||||
"Security": "Segurança",
|
||||
"Select All": "Selecionar tudo",
|
||||
"Selection": "Seleção",
|
||||
"Send": "Enviar",
|
||||
"Send Anyway": "Enviar",
|
||||
"Send message": "Enviar a mensagem.",
|
||||
"Send new messages from:": "Enviar mensagens novas de:",
|
||||
"Services": "Serviços",
|
||||
"Share": "Partilhar",
|
||||
"Show": "Mostrar",
|
||||
"Show All": "Mostrar tudo",
|
||||
"Show Detail": "Mostrar detalhes",
|
||||
"Show Sidebar": "Mostrar barra lateral",
|
||||
"Show more": "Mostrar mais",
|
||||
"Signatures": "Assinaturas",
|
||||
"Small": "Pequeno",
|
||||
"Star": "Estrela",
|
||||
"Stop": "Parar",
|
||||
"Subject": "Assunto",
|
||||
"Symbols": "Símbolos",
|
||||
"Template": "Modelo",
|
||||
"Templates": "Modelos",
|
||||
"Title": "Título",
|
||||
"To": "Para",
|
||||
"Today": "Hoje",
|
||||
"Tomorrow": "Amanhã",
|
||||
"Trash": "Lixo",
|
||||
"Try Again": "Voltar a tentar",
|
||||
"Underline": "Sublinhado",
|
||||
"Undo": "Desfazer",
|
||||
"Unread": "Por ler",
|
||||
"Untitled": "Sem nome",
|
||||
"Updates": "Atualizações",
|
||||
"Upgrade": "Atualizar",
|
||||
"View": "Visualização",
|
||||
"Window": "Janela",
|
||||
"Yes": "Sim",
|
||||
"Zoom": "Aumentar/reduzir janela",
|
||||
"attachments": "anexos",
|
||||
"in %@": "em %@",
|
||||
"seconds": "segundos"
|
||||
}
|
||||
|
|
@ -3,6 +3,9 @@ const path = require('path');
|
|||
|
||||
let files = [];
|
||||
|
||||
const PATH_TO_LANG = __dirname + '/../app/lang';
|
||||
const PATH_TO_ENGLISH = `${PATH_TO_LANG}/en.json`;
|
||||
|
||||
function collectFiles(dir) {
|
||||
fs.readdirSync(dir).forEach(file => {
|
||||
const p = path.join(dir, file);
|
||||
|
|
@ -14,21 +17,21 @@ function collectFiles(dir) {
|
|||
});
|
||||
}
|
||||
|
||||
function writeTerms(keys) {
|
||||
function writeTerms(terms, destPath) {
|
||||
const ordered = {};
|
||||
Object.keys(keys)
|
||||
Object.keys(terms)
|
||||
.sort()
|
||||
.forEach(function(key) {
|
||||
ordered[key] = keys[key];
|
||||
ordered[key] = terms[key];
|
||||
});
|
||||
fs.writeFileSync(__dirname + '/../app/lang/en.json', JSON.stringify(ordered, null, 2));
|
||||
fs.writeFileSync(destPath, JSON.stringify(ordered, null, 2));
|
||||
}
|
||||
|
||||
collectFiles(__dirname + '/../app/src');
|
||||
collectFiles(__dirname + '/../app/internal_packages');
|
||||
collectFiles(__dirname + '/../app/menus');
|
||||
|
||||
let keys = [];
|
||||
let sourceTerms = [];
|
||||
let found = 0;
|
||||
|
||||
const start = /localized(?:ReactFragment)?\((['`"]{1})/g;
|
||||
|
|
@ -46,10 +49,38 @@ files.forEach(file => {
|
|||
const base = js.substr(startIndex, endIndex - startIndex);
|
||||
|
||||
found += 1;
|
||||
keys[base] = base;
|
||||
sourceTerms[base] = base;
|
||||
}
|
||||
});
|
||||
|
||||
console.log(`Found strings: ${found} localized() calls, ${Object.keys(keys).length} strings`);
|
||||
console.log('\nUpdating en.json to match strings in source:');
|
||||
console.log(`- ${found} localized() calls, ${Object.keys(sourceTerms).length} strings`);
|
||||
writeTerms(sourceTerms, PATH_TO_ENGLISH);
|
||||
|
||||
writeTerms(keys);
|
||||
// Open other localization files, remove unneeded entries
|
||||
// and summarize localization progress
|
||||
|
||||
console.log('\nPruning localized strings files:');
|
||||
console.log('\nLang\t\tStrings\t\t\tPercent');
|
||||
console.log('------------------------------------------------');
|
||||
fs.readdirSync(PATH_TO_LANG).forEach(filename => {
|
||||
if (!filename.endsWith('.json')) return;
|
||||
const localePath = path.join(PATH_TO_LANG, filename);
|
||||
const localized = JSON.parse(fs.readFileSync(localePath).toString());
|
||||
|
||||
const inuse = {};
|
||||
Object.keys(localized).forEach(term => {
|
||||
if (sourceTerms[term]) {
|
||||
inuse[term] = localized[term];
|
||||
}
|
||||
});
|
||||
writeTerms(inuse, localePath);
|
||||
|
||||
const c = Object.keys(inuse).length;
|
||||
const t = Object.keys(sourceTerms).length;
|
||||
const lang = path.basename(filename, '.json');
|
||||
|
||||
console.log(
|
||||
`- ${lang}\t${lang.length < 6 ? '\t' : ''}${c}\t/ ${t}\t\t${Math.round(c / t * 100)}%`
|
||||
);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue