Brazilian Portuguese (#203)
* added Brazilian Portuguese * more dictionary processing scripts
This commit is contained in:
parent
f146eaeae2
commit
cd03dec9ff
11 changed files with 261722 additions and 18 deletions
261487
assets/pt-BR-utf8.csv
Normal file
261487
assets/pt-BR-utf8.csv
Normal file
File diff suppressed because it is too large
Load diff
19
res/drawable-anydpi-v24/ime_lang_br.xml
Normal file
19
res/drawable-anydpi-v24/ime_lang_br.xml
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="142"
|
||||
android:viewportHeight="168.75"
|
||||
android:tint="#FFFFFF">
|
||||
<group android:scaleX="0.77416295"
|
||||
android:scaleY="0.92"
|
||||
android:translateX="16.03443"
|
||||
android:translateY="6.75">
|
||||
<group android:translateY="133.59375">
|
||||
<path android:pathData="M10.40625,-0L10.40625,-103L45.5,-103Q62.859375,-103,71.921875,-95.953125Q81,-88.921875,81,-74.984375Q81,-67.859375,77.203125,-62.171875Q73.40625,-56.484375,66.09375,-53.359375Q74.390625,-51.109375,78.921875,-44.875Q83.46875,-38.640625,83.46875,-29.90625Q83.46875,-15.484375,74.21875,-7.734375Q64.96875,-0,47.75,-0L10.40625,-0ZM28.203125,-46L28.203125,-14.296875L47.953125,-14.296875Q56.328125,-14.296875,61.03125,-18.453125Q65.75,-22.609375,65.75,-30Q65.75,-46,49.4375,-46L28.203125,-46ZM28.203125,-59.375L45.640625,-59.375Q53.9375,-59.375,58.609375,-63.1875Q63.28125,-67,63.28125,-74Q63.28125,-81.703125,58.953125,-85.125Q54.640625,-88.5625,45.5,-88.5625L28.203125,-88.5625L28.203125,-59.375Z"
|
||||
android:fillColor="#000000"/>
|
||||
<path android:pathData="M139.59375,-60.875Q136.21875,-61.4375,132.625,-61.4375Q120.890625,-61.4375,116.8125,-52.375L116.8125,0L99.71875,0L99.71875,-76.578125L116.03125,-76.578125L116.453125,-68.015625Q122.640625,-78,133.60938,-78Q137.26562,-78,139.65625,-77L139.59375,-60.875Z"
|
||||
android:fillColor="#000000"/>
|
||||
</group>
|
||||
</group>
|
||||
</vector>
|
||||
BIN
res/drawable-hdpi/ime_lang_br.png
Normal file
BIN
res/drawable-hdpi/ime_lang_br.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 413 B |
BIN
res/drawable-mdpi/ime_lang_br.png
Normal file
BIN
res/drawable-mdpi/ime_lang_br.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 279 B |
BIN
res/drawable-xhdpi/ime_lang_br.png
Normal file
BIN
res/drawable-xhdpi/ime_lang_br.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 483 B |
BIN
res/drawable-xxhdpi/ime_lang_br.png
Normal file
BIN
res/drawable-xxhdpi/ime_lang_br.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 854 B |
62
res/values-pt-rBR/strings.xml
Normal file
62
res/values-pt-rBR/strings.xml
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string translatable="false" name="help_url">https://github.com/sspanak/tt9/blob/master/docs/user-manual.md</string>
|
||||
<string name="app_name" translatable="false">Traditional T9</string>
|
||||
<string name="app_settings">Configurações do Teclado</string>
|
||||
<string name="completed">Concluído</string>
|
||||
<string name="error_unexpected">Um erro inesperado aconteceu.</string>
|
||||
|
||||
<string name="add_word_add">Adicionar</string>
|
||||
<string name="add_word_blank">Palavra em branco, impossível adicionar.</string>
|
||||
<string name="add_word_exist">Palavra \"%1$s\" já está registrada.</string>
|
||||
<string name="add_word_invalid_language" translatable="false">Cannot add a word when no language is selected</string>
|
||||
<string name="add_word_title">Adicionar Palavra</string>
|
||||
<string name="add_word_field_placeholder">Escreva uma palavra…</string>
|
||||
|
||||
<string name="pref_category_about">Sobre</string>
|
||||
<string name="pref_category_appearance">Aparência</string>
|
||||
<string name="pref_category_predictive_mode">Modo Predictivo</string>
|
||||
<string name="pref_category_function_keys">Atalhos</string>
|
||||
<string name="pref_category_keypad">Teclado</string>
|
||||
|
||||
<string name="pref_auto_space">Espaçamento Automático</string>
|
||||
<string name="pref_auto_space_summary">Insere um espaçamento após ponto final.</string>
|
||||
<string name="pref_auto_text_case">Maiúsculas Automáticas</string>
|
||||
<string name="pref_auto_text_case_summary">Inicia automaticamente com letras maiúsculas.</string>
|
||||
<string name="pref_choose_languages">Idiomas</string>
|
||||
<string name="pref_dark_theme">Modo Escuro</string>
|
||||
<string name="pref_double_zero_char">Caractere para toque duplo na tecla 0</string>
|
||||
<string name="pref_show_soft_function_keys">Mostrar teclas de funções na tela</string>
|
||||
<string name="pref_help">Ajuda</string>
|
||||
|
||||
<string name="dictionary_cancel_load">Cancelar Carregamento</string>
|
||||
<string name="dictionary_load_bad_char">Falha no carregamento. \"%1$s\" na linha %2$d do idioma \"%3$s\".</string>
|
||||
<string name="dictionary_load_error">Falha no carregamento do dicionário para o idioma \"%1$s\" (%2$s).</string>
|
||||
<string name="dictionary_load_cancelled">Carregamento de dicionário cancelado.</string>
|
||||
<string name="dictionary_loaded">Dicionário carregado com sucesso.</string>
|
||||
<string name="dictionary_loading">Carregando dicionário (%1$s)…</string>
|
||||
<string name="dictionary_loading_indeterminate">Carregando dicionário…</string>
|
||||
<string name="dictionary_load_title">Carregar Dicionário</string>
|
||||
<string name="dictionary_missing_go_load_it">Não há um dicionário para o idioma \"%1$s\". É possível carregá-lo em "Configurações".</string>
|
||||
<string name="dictionary_not_found">Falha no carregamento. Não foi encontrado um dicionário para o idioma \"%1$s\".</string>
|
||||
<string name="dictionary_truncate_title">Limpar Dicionário</string>
|
||||
<string name="dictionary_truncated">Dicionário apagado com sucesso.</string>
|
||||
|
||||
<string name="function_add_word_key">Adicionar palavra</string>
|
||||
<string name="function_backspace_key">Backspace</string>
|
||||
<string name="function_next_language_key">Próximo Idioma</string>
|
||||
<string name="function_next_mode_key">Modo de Entrada</string>
|
||||
<string name="function_show_settings_key">Entrar em Configurações</string>
|
||||
<string name="function_reset_keys_title">Restaurar Atalhos Padrão</string>
|
||||
<string name="function_reset_keys_done">Atalhos Restaurados.</string>
|
||||
|
||||
<string name="key_hold_key">(segurar)</string>
|
||||
<string name="key_back">Voltar</string>
|
||||
<string name="key_call">Chamada</string>
|
||||
|
||||
<string name="char_newline">Nova Linha</string>
|
||||
<string name="char_space">Espaço</string>
|
||||
<string name="pref_upside_down_keys_summary">Utilize essa opção se você possuir as teclas 7–8–9 na linha de cima, ao invés de 1–2–3.</string>
|
||||
<string name="pref_upside_down_keys">Inverter Ordem das Teclas</string>
|
||||
<string name="dictionary_truncate_unselected">Limpar Não Selecionados</string>
|
||||
</resources>
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
const { basename } = require('path');
|
||||
const { createReadStream, existsSync } = require('fs');
|
||||
|
||||
const { createInterface } = require('readline');
|
||||
|
||||
const GEO_NAME = /[A-Z]\w+\-[^\n]+/;
|
||||
|
||||
|
|
@ -40,37 +40,49 @@ function getRegularWordKey(locale, word) {
|
|||
|
||||
|
||||
|
||||
function getWordKeyPreservingCaptialization(locale, word, wordMap) {
|
||||
if (typeof word !== 'string' || word.length === 0 || typeof wordMap !== 'object') {
|
||||
function getLowercaseWordKey(locale, word) {
|
||||
return getWordkey(word).toLocaleLowerCase(locale);
|
||||
}
|
||||
|
||||
|
||||
|
||||
function getWordkey(word) {
|
||||
if (typeof word !== 'string' || word.length === 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
let wordKey = word.toLocaleLowerCase(locale);
|
||||
|
||||
if (GEO_NAME.test(word) || word.toLocaleLowerCase(locale) !== word) {
|
||||
wordKey = word;
|
||||
if (wordMap[word.toLocaleLowerCase(locale)]) {
|
||||
delete wordMap[word.toLocaleLowerCase(locale)];
|
||||
}
|
||||
}
|
||||
|
||||
return wordKey;
|
||||
return word;
|
||||
}
|
||||
|
||||
|
||||
|
||||
async function removeRepeatingWords({ fileName, locale }) {
|
||||
const lineReader = require('readline').createInterface({
|
||||
input: createReadStream(fileName)
|
||||
});
|
||||
|
||||
const wordMap = {};
|
||||
|
||||
let lineReader = createInterface({ input: createReadStream(fileName) });
|
||||
for await (const line of lineReader) {
|
||||
wordMap[getWordKeyPreservingCaptialization(locale, line, wordMap)] = true;
|
||||
wordMap[getLowercaseWordKey(locale, line)] = true;
|
||||
}
|
||||
|
||||
return Object.keys(wordMap);
|
||||
|
||||
lineReader = createInterface({ input: createReadStream(fileName) });
|
||||
for await (const line of lineReader) {
|
||||
const word = getWordkey(line);
|
||||
const lowercaseWord = getLowercaseWordKey(locale, line);
|
||||
|
||||
if (word === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (word !== lowercaseWord) {
|
||||
delete wordMap[lowercaseWord];
|
||||
wordMap[word] = true;
|
||||
}
|
||||
}
|
||||
|
||||
return Object.keys(wordMap).sort();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
98
scripts/remove-foreign-words.js
Normal file
98
scripts/remove-foreign-words.js
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
const { basename } = require('path');
|
||||
const { createReadStream, existsSync } = require('fs');
|
||||
const { createInterface } = require('readline');
|
||||
|
||||
|
||||
function printHelp() {
|
||||
console.log(`Usage ${basename(process.argv[1])} DICTIONARY_LOCALE DICTIONARY.TXT FOREIGN_WORDS_LOCALE FOREIGN-WORD-DICTIONARY.txt`);
|
||||
console.log('Removes foreign words from a dictionary');
|
||||
}
|
||||
|
||||
|
||||
|
||||
function validateInput() {
|
||||
if (process.argv.length < 6) {
|
||||
printHelp();
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (!existsSync(process.argv[3])) {
|
||||
console.error(`Failure! Could not find words file "${process.argv[3]}."`);
|
||||
process.exit(2);
|
||||
}
|
||||
|
||||
if (!existsSync(process.argv[5])) {
|
||||
console.error(`Failure! Could not find foreign words file "${process.argv[4]}."`);
|
||||
process.exit(2);
|
||||
}
|
||||
|
||||
return {
|
||||
locale: process.argv[2],
|
||||
fileName: process.argv[3],
|
||||
foreignWordsLocale: process.argv[4],
|
||||
foreignWordsFileName: process.argv[5]
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
function getLowercaseWordKey(locale, word) {
|
||||
return getWordkey(word).toLocaleLowerCase(locale);
|
||||
}
|
||||
|
||||
|
||||
|
||||
function getWordkey(word) {
|
||||
if (typeof word !== 'string' || word.length === 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return word;
|
||||
}
|
||||
|
||||
|
||||
|
||||
async function removeForeignWords({ locale, foreignWordsLocale, fileName, foreignWordsFileName }) {
|
||||
const foreignWords = {};
|
||||
|
||||
let lineReader = createInterface({ input: createReadStream(foreignWordsFileName) });
|
||||
for await (const line of lineReader) {
|
||||
foreignWords[getLowercaseWordKey(foreignWordsLocale, line)] = true;
|
||||
}
|
||||
|
||||
|
||||
const wordMap = {};
|
||||
lineReader = createInterface({ input: createReadStream(fileName) });
|
||||
for await (const line of lineReader) {
|
||||
const word = getWordkey(line);
|
||||
const lowercaseWord = getLowercaseWordKey(locale, line);
|
||||
|
||||
if (word === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (!foreignWords[lowercaseWord]) {
|
||||
wordMap[word] = true;
|
||||
}
|
||||
}
|
||||
|
||||
return Object.keys(wordMap);
|
||||
}
|
||||
|
||||
|
||||
|
||||
function printWords(wordList) {
|
||||
if (!Array.isArray(wordList)) {
|
||||
return;
|
||||
}
|
||||
|
||||
wordList.forEach(w => console.log(w));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** main **/
|
||||
removeForeignWords(validateInput())
|
||||
.then(words => printWords(words))
|
||||
.catch(e => console.error(e));
|
||||
|
|
@ -21,6 +21,7 @@ public class LanguageCollection {
|
|||
List<Class<? extends Language>> languageList = Arrays.asList(
|
||||
// Add languages here, to enable them in the UI and
|
||||
// please, maintain the alphabetical order.
|
||||
BrazilianPortuguese.class,
|
||||
Bulgarian.class,
|
||||
Dutch.class,
|
||||
English.class,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,25 @@
|
|||
package io.github.sspanak.tt9.languages.definitions;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Locale;
|
||||
|
||||
import io.github.sspanak.tt9.R;
|
||||
|
||||
public class BrazilianPortuguese extends English {
|
||||
public BrazilianPortuguese() {
|
||||
super();
|
||||
|
||||
name = "Português brasileiro";
|
||||
locale = new Locale("pt","BR");
|
||||
dictionaryFile = "pt-BR-utf8.csv";
|
||||
icon = R.drawable.ime_lang_br;
|
||||
|
||||
isPunctuationPartOfWords = true;
|
||||
|
||||
characterMap.get(2).addAll(Arrays.asList("ç", "á", "â", "ã", "à"));
|
||||
characterMap.get(3).addAll(Arrays.asList("é", "ê", "è"));
|
||||
characterMap.get(4).add("í");
|
||||
characterMap.get(6).addAll(Arrays.asList("ó", "ô", "õ"));
|
||||
characterMap.get(8).add("ú");
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue