From 55ef7b50b54939f66b37a71e21c235afca03265e Mon Sep 17 00:00:00 2001 From: Georg Baum Date: Wed, 23 Mar 2011 19:17:15 +0000 Subject: [PATCH] First version of separate translation machinery for strings that go into exported documents. To update the translations from the .po files, run make ../lib/layouttranslations from po. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@38016 a592a061-630c-0410-9148-cb99ea01b6c8 --- development/scons/scons_manifest.py | 1 + lib/Makefile.am | 2 +- lib/layouttranslations | 1147 +++++++++++++++++++++++++++ po/Rules-lyx | 5 + po/lyx_pot.py | 120 ++- src/LaTeXFeatures.cpp | 3 +- src/Language.cpp | 100 +++ src/Language.h | 20 +- src/Layout.cpp | 9 +- 9 files changed, 1377 insertions(+), 30 deletions(-) create mode 100644 lib/layouttranslations diff --git a/development/scons/scons_manifest.py b/development/scons/scons_manifest.py index 7f4873da0b..450dd6b200 100644 --- a/development/scons/scons_manifest.py +++ b/development/scons/scons_manifest.py @@ -1288,6 +1288,7 @@ lib_files = Split(''' encodings external_templates languages + layouttranslations symbols syntax.default unicodesymbols diff --git a/lib/Makefile.am b/lib/Makefile.am index 72d1e14f1d..dc716beb05 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -5,7 +5,7 @@ SUBDIRS = doc lyx2lyx CHMOD = chmod dist_pkgdata_DATA = CREDITS chkconfig.ltx external_templates encodings \ - languages symbols syntax.default unicodesymbols + layouttranslations languages symbols syntax.default unicodesymbols # Note that we "chmod 755" manually this file in install-data-hook. dist_pkgdata_PYTHON = configure.py diff --git a/lib/layouttranslations b/lib/layouttranslations new file mode 100644 index 0000000000..2f7e8d720a --- /dev/null +++ b/lib/layouttranslations @@ -0,0 +1,1147 @@ +# This file has been automatically generated by po/lyx_pot.py. +# PLEASE DO NOT MODIFY ANYTHING HERE! If you want to regenerate this file +# from the translations, run `make ../lib/layouttranslations' in po. + +Translation ar + "Algorithm" "الخوارزم" + "Assumption" "فرضية" + "Axiom" "مسلمة" + "Chart" "جدول بياني" + "Conclusion" "استنتاج" + "Condition" "شرط" + "Definition" "تعريف" + "Example" "مثال" + "Exercise" "تمرين" + "Fact" "حقيقة" + "Figure" "صورة توضيحية" + "Graph" "رسم بياني" + "List of Algorithms" "قائمة الخوارزميات" + "List of Charts" "قائمة الجداول البيانية" + "List of Figures" "قائمة الرسوم التوضيحية" + "List of Graphs" "قائمة الرسوم البيانية" + "List of Schemes" "قائمة التصميمات" + "List of Tableaux" "قائمة الجداول" + "List of Tables" "قائمة الجداول" + "MarginFigure" "صورة هامشية" + "MarginTable" "جدول هامشي" + "Notation" "تدوين" + "Note" "ملاحظة" + "Problem" "مشكلة" + "Proof" "برهان" + "Question" "سؤال" + "Remark" "ملاحظة" + "Scheme" "مخطط" + "Summary" "موجز" + "Table" "جدول" + "Tableau" "جدول" + "Theorem" "نظرية" +End + +Translation bg + "Algorithm" "Aлгоритъм" + "Conclusion" "Заключение" + "Condition" "Условие" + "Definition" "Дефиниция" + "Example" "Пример" + "Exercise" "Упражнение" + "Fact" "Факт" + "Lemma" "Лема" + "Note" "Бележка" + "Problem" "Проблем" + "Proof" "Доказателство" + "Proposition" "Допускане" + "Question" "Въпрос" + "Summary" "Обобщение" + "Theorem" "Теорема" +End + +Translation ca + "Acknowledgement" "Agraiment" + "Algorithm" "Algorisme" + "Assumption" "Assumpció" + "Axiom" "Axioma" + "Case" "Cas" + "Claim" "Afirmació" + "Conclusion" "Conclusió" + "Condition" "Condició" + "Conjecture" "Conjectura" + "Corollary" "Corol·lari" + "Criterion" "Criteri" + "Definition" "Definició" + "Example" "Exemple" + "Exercise" "Exercici" + "Fact" "Fet" + "Figure" "Figura" + "Lemma" "Lema" + "List of Algorithms" "Llista d'algorismes" + "List of Figures" "Llista de figures" + "List of Tables" "Llista de taules" + "Notation" "Notació" + "Note" "Nota" + "Problem" "Problema" + "Proof" "Demostració" + "Proposition" "Proposició" + "Question" "Qüestió" + "Remark" "Comentari" + "Summary" "Resum" + "Table" "Taula" + "Theorem" "Teorema" +End + +Translation cs + "Algorithm" "Algoritmus" + "Example" "Příklad" + "Figure" "Obrázek" + "List of Algorithms" "Seznam algoritmů" + "List of Figures" "Seznam obrázků" + "List of Tableaux" "Seznam tabel" + "List of Tables" "Seznam tabulek" + "Note" "Pozn." + "Table" "Tabulka" + "Tableau" "Tablo" +End + +Translation da + "Acknowledgement" "Taksigelse" + "Algorithm" "Algoritme" + "Axiom" "Aksiom" + "Case" "Sag" + "Claim" "Påstand" + "Conclusion" "Konklusion" + "Condition" "Betingelse" + "Conjecture" "Formodning" + "Corollary" "Korollar" + "Criterion" "Kriterie" + "Example" "Eksempel" + "Exercise" "Øvelse" + "Fact" "Fakta" + "Figure" "Figur" + "Note" "Notat" + "Planotable" "PlanoTabel" + "Plate" "Plade" + "Proof" "Korrektur" + "Proposition" "Forslag" + "Question" "Spørgsmål" + "Remark" "Bemærkning" + "Summary" "Sammenfatning" + "Table" "Tabel" + "Theorem" "Teorem" +End + +Translation de + "Acknowledgement" "Danksagung" + "Algorithm" "Algorithmus" + "Assumption" "Annahme" + "Case" "Fall" + "Chart" "Zeichnung" + "Claim" "Behauptung" + "Conclusion" "Schlussfolgerung" + "Condition" "Bedingung" + "Conjecture" "Vermutung" + "Corollary" "Korollar" + "Criterion" "Kriterium" + "Example" "Beispiel" + "Exercise" "Aufgabe" + "Fact" "Fakt" + "Figure" "Abbildung" + "List of Algorithms" "Algorithmenverzeichnis" + "List of Charts" "Liste der Zeichnungen" + "List of Figures" "Abbildungsverzeichnis" + "List of Graphs" "Liste der Graphen" + "List of Schemes" "Liste der Schemata" + "List of Tableaux" "Tableaux-Verzeichnis" + "List of Tables" "Tabellenverzeichnis" + "MarginFigure" "Randabbildung" + "MarginTable" "Randtabelle" + "Note" "Notiz" + "Planotable" "Plano-Tabelle" + "Plate" "Bildtafel" + "Proof" "Beweis" + "Question" "Frage" + "Remark" "Bemerkung" + "Scheme" "Schema" + "Summary" "Zusammenfassung" + "Table" "Tabelle" +End + +Translation el + "Acknowledgement" "Μνεία" + "Algorithm" "Αλγόριθμος" + "Assumption" "Υπόθεση" + "Axiom" "Αξίωμα" + "Case" "Περίπτωση" + "Chart" "Γραφική Παράσταση" + "Claim" "Ισχυρισμός" + "Conclusion" "Συμπέρασμα" + "Condition" "Συνθήκη" + "Conjecture" "Εικασία" + "Corollary" "Πόρισμα" + "Criterion" "Κριτήριο" + "Definition" "Ορισμός" + "Example" "Παράδειγμα" + "Exercise" "Άσκηση" + "Fact" "Δεδομένο" + "Figure" "Εικόνα" + "Graph" "Γράφημα" + "Lemma" "Λήμμα" + "List of Algorithms" "Λίστα Αλγορίθμων" + "List of Charts" "Λίστα Γραφικών Παραστάσεων" + "List of Figures" "Λίστα Εικόνων" + "List of Graphs" "Λίστα Γραφημάτων" + "List of Schemes" "Λίστα Σχεδίων" + "List of Tableaux" "Λίστα Ταμπλό" + "List of Tables" "Λίστα Πινάκων" + "Notation" "Σημειογραφία" + "Note" "Σημείωση" + "Problem" "Πρόβλημα" + "Proof" "Απόδειξη" + "Proposition" "Πρόταση" + "Question" "Ερώτημα" + "Remark" "Παρατήρηση" + "Scheme" "Σχέδιο" + "Summary" "Σύνοψη" + "Table" "Πίνακας" + "Tableau" "Ταμπλό" + "Theorem" "Θεώρημα" +End + +Translation en +End + +Translation es + "Acknowledgement" "Agradecimiento" + "Algorithm" "Algoritmo" + "Assumption" "Suposición" + "Axiom" "Axioma" + "Case" "Caso" + "Chart" "Diagrama" + "Claim" "Afirmación" + "Conclusion" "Conclusión" + "Condition" "Condición" + "Conjecture" "Conjetura" + "Corollary" "Corolario" + "Criterion" "Criterio" + "Definition" "Definición" + "Example" "Ejemplo" + "Exercise" "Ejercicio" + "Fact" "Hecho" + "Figure" "Figura" + "Graph" "Gráfico" + "Lemma" "Lema" + "List of Algorithms" "Índice de algoritmos" + "List of Charts" "Lista de diagramas" + "List of Figures" "Índice de figuras" + "List of Graphs" "Lista de gráficos" + "List of Schemes" "Lista de esquemas" + "List of Tableaux" "Índice de Tableaux" + "List of Tables" "Índice de tablas" + "MarginFigure" "Figura al margen" + "MarginTable" "Tabla al margen" + "Notation" "Notación" + "Note" "Nota" + "Plate" "Lámina" + "Problem" "Problema" + "Proof" "Demostración" + "Proposition" "Proposición" + "Question" "Pregunta" + "Remark" "Observación" + "Scheme" "Esquema" + "Summary" "Resumen" + "Table" "Tabla" + "Theorem" "Teorema" +End + +Translation eu + "Acknowledgement" "Aitorpena" + "Algorithm" "Algoritmoa" + "Assumption" "Hipotesia" + "Axiom" "Axioma" + "Case" "Kasua" + "Chart" "Diagrama" + "Claim" "Aldarrikapena" + "Conclusion" "Ondorioa" + "Condition" "Baldintza" + "Conjecture" "Aierua" + "Corollary" "Korolarioa" + "Criterion" "Irizpidea" + "Definition" "Definizioa" + "Example" "Adibidea" + "Exercise" "Ariketa" + "Fact" "Egitatea" + "Figure" "Irudia" + "Graph" "Grafikoa" + "Lemma" "Lema" + "List of Algorithms" "Algoritmoen zerrenda" + "List of Charts" "Diagramen zerrenda" + "List of Figures" "Irudien zerrenda" + "List of Graphs" "Grafikoen zerrenda" + "List of Schemes" "Eskemen zerrenda" + "List of Tableaux" "Taulen zerrenda" + "List of Tables" "Taulen zerrenda" + "MarginFigure" "Albo-irudia" + "MarginTable" "Albo-taula" + "Notation" "Notazioa" + "Note" "Ohar" + "Planotable" "Taula-xafla" + "Plate" "Xafla" + "Problem" "Buruketa" + "Proof" "Frogapena" + "Proposition" "Proposizioa" + "Question" "Galdera" + "Remark" "Oharra" + "Scheme" "Eskema" + "Summary" "Laburpena" + "Table" "Taula" + "Tableau" "Taula" + "Theorem" "Teorema" +End + +Translation fi + "Acknowledgement" "Kiitos" + "Algorithm" "Algoritmi" + "Axiom" "Aksiooma" + "Case" "Tapaus" + "Claim" "Väite" + "Conclusion" "Päätelmä" + "Condition" "Ehto" + "Conjecture" "Otaksuma" + "Corollary" "Seurauslause" + "Criterion" "Kriteeri" + "Definition" "Määritelmä" + "Example" "Esimerkki" + "Exercise" "Harjoitus" + "Fact" "Fakta" + "Figure" "Kuva" + "List of Algorithms" "Algoritmien taulukko" + "List of Figures" "Kuvien luettelo" + "List of Tables" "Taulukoiden luettelo" + "Notation" "Merkintätapa" + "Note" "Muistiinpano" + "Planotable" "Kokosivutaulukko" + "Plate" "Kiiltokuva" + "Problem" "Ongelma" + "Proof" "Todistus" + "Proposition" "Väittämä" + "Question" "Kysymys" + "Remark" "Huomautus" + "Summary" "Yhteenveto" + "Table" "Taulukko" + "Theorem" "Lause" +End + +Translation fr + "Acknowledgement" "Remerciement" + "Algorithm" "Algorithme" + "Assumption" "Hypothèse" + "Axiom" "Axiome" + "Case" "Cas" + "Chart" "Diagramme" + "Claim" "Affirmation" + "Corollary" "Corollaire" + "Criterion" "Critère" + "Definition" "Définition" + "Example" "Exemple" + "Exercise" "Exercice" + "Fact" "Fait" + "Graph" "Graphique" + "Lemma" "Lemme" + "List of Algorithms" "Liste des algorithmes" + "List of Charts" "Liste des diagrammes" + "List of Figures" "Liste des figures" + "List of Graphs" "Liste des graphiques" + "List of Schemes" "Liste des schémas" + "List of Tableaux" "Liste des tableaux (TO)" + "List of Tables" "Liste des tableaux" + "MarginFigure" "Figure en marge" + "MarginTable" "Table en marge" + "Planotable" "PlancheTableau" + "Plate" "Planche" + "Problem" "Problème" + "Proof" "Preuve" + "Remark" "Remarque" + "Scheme" "Schéma" + "Summary" "Résumé" + "Table" "Tableau" + "Theorem" "Théorème" +End + +Translation gl + "Acknowledgement" "Agradecimento" + "Algorithm" "Algoritmo" + "Assumption" "Suposición" + "Axiom" "Axioma" + "Case" "Caso" + "Claim" "Afirmación" + "Conclusion" "Conclusión" + "Condition" "Condición" + "Conjecture" "Conxetura" + "Corollary" "Corolário" + "Criterion" "Critério" + "Definition" "Definición" + "Example" "Exemplo" + "Exercise" "Exercício" + "Fact" "Facto" + "Figure" "Figura" + "Lemma" "Lema" + "List of Algorithms" "Lista de algoritmos" + "List of Figures" "Lista de figuras" + "List of Tables" "Lista de táboas" + "Notation" "Notación" + "Note" "Nota" + "Plate" "Lámina" + "Problem" "Problema" + "Proof" "Demostración" + "Proposition" "Proposición" + "Question" "Pergunta" + "Remark" "Observación" + "Summary" "Resumo" + "Table" "Táboa" + "Theorem" "Teorema" +End + +Translation he + "Acknowledgement" "הכרת תודה" + "Algorithm" "אלגוריתם" + "Axiom" "אקסיומה" + "Case" "תנאי" + "Claim" "טענה" + "Condition" "תנאי" + "Corollary" "מסקנה" + "Criterion" "קריטריון" + "Definition" "הגדרה" + "Example" "דוגמה" + "Exercise" "תרגיל" + "Fact" "עובדה" + "Figure" "איור" + "Lemma" "למה" + "List of Algorithms" "רשימת אלגוריתמים" + "List of Figures" "רשימת איורים" + "List of Tables" "רשימת טבלאות" + "Note" "הערה" + "Problem" "בעיה" + "Proof" "הוכחה" + "Proposition" "הצעה" + "Question" "שאלה" + "Remark" "הערה" + "Summary" "סיכום" + "Table" "טבלה" + "Theorem" "משפט" +End + +Translation hu + "Acknowledgement" "Köszönetnyilvánítás" + "Algorithm" "Algoritmus" + "Assumption" "Feltevés" + "Axiom" "Axióma" + "Case" "Eset" + "Chart" "Grafikon" + "Claim" "Követelés" + "Conclusion" "Következtetés" + "Condition" "Feltétel" + "Conjecture" "Feltevés" + "Corollary" "Következmény" + "Criterion" "Kritérium" + "Definition" "Definíció" + "Example" "Példa" + "Exercise" "Feladat" + "Fact" "Tény" + "Figure" "Ábra" + "Graph" "Grafika" + "Lemma" "Segédtétel" + "List of Algorithms" "Algoritmusok listája" + "List of Charts" "Grafikonok listája" + "List of Figures" "Ábrák listája" + "List of Graphs" "Ábrák listája" + "List of Schemes" "Sémák listája" + "List of Tableaux" "Csoportképek listája" + "List of Tables" "Táblázatok listája" + "Notation" "Jelölés" + "Note" "Megjegyzés" + "Problem" "Probléma" + "Proof" "Bizonyítás" + "Proposition" "Javaslat" + "Question" "Kérdés" + "Remark" "Észrevétel" + "Scheme" "Séma" + "Summary" "Összegzés" + "Table" "Táblázat" + "Tableau" "Csoportkép" + "Theorem" "Tétel" +End + +Translation ia + "Acknowledgement" "Riconoscimento" + "Algorithm" "Algoritmo" + "Assumption" "Assunzione" + "Axiom" "Assioma" + "Case" "Caso" + "Chart" "Diagramma" + "Claim" "Asserzione" + "Conclusion" "Conclusione" + "Condition" "Condizione" + "Conjecture" "Congettura" + "Corollary" "Corollario" + "Criterion" "Criterio" + "Definition" "Definizione" + "Example" "Esempio" + "Exercise" "Esercizio" + "Fact" "Fatto" + "Figure" "Figura" + "Graph" "Grafico" + "List of Algorithms" "Elenco degli algoritmi|a" + "List of Charts" "Elenco dei diagrammi" + "List of Figures" "Elenco delle figure" + "List of Graphs" "Elenco dei grafici" + "List of Schemes" "Elenco degli schemi" + "List of Tableaux" "Elenco dei tableau" + "List of Tables" "Elenco delle tabelle" + "MarginFigure" "Figura a margine" + "MarginTable" "Tabella a margine" + "Notation" "Notazione" + "Note" "Nota" + "Plate" "Foglio" + "Problem" "Problema" + "Proof" "Dimostrazione" + "Proposition" "Proposizione" + "Question" "Questione" + "Remark" "Osservazione" + "Scheme" "Schema" + "Summary" "Sommario" + "Table" "Tabella" + "Theorem" "Teorema" +End + +Translation id + "Algorithm" "Algoritma" + "Assumption" "Asumsi" + "Case" "Kasus" + "Chart" "Diagram" + "Claim" "Klaim" + "Conclusion" "Simpulan" + "Condition" "Kondisi" + "Conjecture" "Dugaan" + "Criterion" "Kriteria" + "Definition" "Definisi" + "Example" "Contoh" + "Exercise" "Latihan" + "Fact" "Fakta" + "Figure" "Gambar" + "Graph" "Grafik" + "List of Algorithms" "Daftar Algoritma" + "List of Charts" "Daftar Diagram" + "List of Figures" "Daftar Gambar" + "List of Graphs" "Daftar Grafik" + "List of Schemes" "Daftar Skema" + "List of Tableaux" "Daftar Tableaux" + "List of Tables" "Daftar Tabel" + "MarginFigure" "GambarTepi" + "MarginTable" "TabelTepi" + "Notation" "Notasi" + "Note" "Nota" + "Planotable" "Tabel Plano" + "Plate" "Pelat" + "Problem" "Masalah" + "Proposition" "Rencana" + "Question" "Pertanyaan" + "Remark" "Catatan" + "Scheme" "Skema" + "Summary" "Ringkasan" + "Table" "Tabel" + "Theorem" "Teorema" +End + +Translation it + "Acknowledgement" "Riconoscimento" + "Algorithm" "Algoritmo" + "Assumption" "Assunzione" + "Axiom" "Assioma" + "Case" "Caso" + "Chart" "Diagramma" + "Claim" "Asserzione" + "Conclusion" "Conclusione" + "Condition" "Condizione" + "Conjecture" "Congettura" + "Corollary" "Corollario" + "Criterion" "Criterio" + "Definition" "Definizione" + "Example" "Esempio" + "Exercise" "Esercizio" + "Fact" "Fatto" + "Figure" "Figura" + "Graph" "Grafico" + "List of Algorithms" "Elenco degli algoritmi|a" + "List of Charts" "Elenco dei diagrammi" + "List of Figures" "Elenco delle figure" + "List of Graphs" "Elenco dei grafici" + "List of Schemes" "Elenco degli schemi" + "List of Tableaux" "Elenco dei tableau" + "List of Tables" "Elenco delle tabelle" + "MarginFigure" "Figura a margine" + "MarginTable" "Tabella a margine" + "Notation" "Notazione" + "Note" "Nota" + "Plate" "Foglio" + "Problem" "Problema" + "Proof" "Dimostrazione" + "Proposition" "Proposizione" + "Question" "Questione" + "Remark" "Osservazione" + "Scheme" "Schema" + "Summary" "Sommario" + "Table" "Tabella" + "Theorem" "Teorema" +End + +Translation ja + "Acknowledgement" "謝辞(Acknowledgement)" + "Algorithm" "アルゴリズム" + "Assumption" "仮定" + "Axiom" "公理" + "Case" "ケース" + "Chart" "チャート" + "Claim" "主張" + "Conclusion" "結論" + "Condition" "条件" + "Conjecture" "推論" + "Corollary" "系" + "Criterion" "基準" + "Definition" "定義" + "Example" "例" + "Exercise" "演習" + "Fact" "事実" + "Figure" "図" + "Graph" "グラフ" + "Lemma" "補題" + "List of Algorithms" "アルゴリズム一覧" + "List of Charts" "チャート一覧" + "List of Figures" "図一覧" + "List of Graphs" "グラフ一覧" + "List of Schemes" "スキーム一覧" + "List of Tableaux" "絵画一覧" + "List of Tables" "表一覧" + "MarginFigure" "傍図" + "MarginTable" "傍表" + "Notation" "記法" + "Note" "注釈" + "Planotable" "平面表(planotable)" + "Plate" "挿絵" + "Problem" "問題" + "Proof" "証明" + "Proposition" "命題" + "Question" "問題" + "Remark" "所見" + "Scheme" "スキーム" + "Summary" "要約" + "Table" "表" + "Tableau" "絵画" + "Theorem" "定理" +End + +Translation ko + "Algorithm" "알고리듬" + "Figure" "그림" + "List of Algorithms" "알고리듬 목록" + "List of Figures" "그림 목록" + "List of Tables" "테이블 목록" + "Note" "노우트(Note)" +End + +Translation nb + "Acknowledgement" "Takk til" + "Algorithm" "Algoritme" + "Assumption" "Antagelse" + "Axiom" "Aksiom" + "Case" "Tilfelle" + "Claim" "Påstand" + "Conclusion" "Konklusjon" + "Condition" "Forutsetning" + "Conjecture" "Konjektur" + "Corollary" "Korollar" + "Criterion" "Kriterie" + "Definition" "Definisjon" + "Example" "Eksempel" + "Exercise" "Øvelse" + "Fact" "Faktum" + "Figure" "Figur" + "List of Algorithms" "Liste over algoritmer" + "List of Figures" "Liste over figurer" + "List of Tables" "Liste over tabeller" + "Notation" "Notasjon" + "Proof" "Bevis" + "Proposition" "Proposisjon" + "Question" "Spørsmål" + "Remark" "Merknad" + "Summary" "Sammendrag" + "Table" "Tabell" + "Theorem" "Teorem" +End + +Translation nl + "Axiom" "Axioma" + "Case" "Casus" + "Conclusion" "Conclusie" + "Definition" "Definitie" + "Example" "Voorbeeld" + "Exercise" "Oefening" + "Fact" "Feit" + "Figure" "Figuur" + "Note" "Notitie" + "Remark" "Opmerking" + "Summary" "Samenvatting" + "Table" "Tabel" +End + +Translation nn + "Acknowledgement" "Takk til" + "Algorithm" "Algoritme" + "Assumption" "Asumpsjon" + "Axiom" "Aksiom" + "Case" "Tilfelle" + "Chart" "Diagram" + "Claim" "Påstand" + "Conclusion" "Konklusjon" + "Condition" "Vilkår" + "Conjecture" "Konjektur" + "Corollary" "Korollar" + "Criterion" "Kriterium" + "Definition" "Definisjon" + "Example" "Døme" + "Exercise" "Øving" + "Fact" "Faktum" + "Figure" "Figur" + "Graph" "Grafar" + "List of Algorithms" "Liste over algoritmer" + "List of Charts" "Liste over diagram" + "List of Figures" "Liste over figurar" + "List of Graphs" "Liste over grafar" + "List of Schemes" "Liste over skjema" + "List of Tableaux" "Liste over tablå" + "List of Tables" "Liste over tabellar" + "MarginFigure" "MargFigur" + "MarginTable" "Margtabell" + "Notation" "Notasjon" + "Note" "Notis" + "Planotable" "Plano- tabell" + "Proof" "Prov" + "Proposition" "Framlegg" + "Question" "Spørsmål" + "Remark" "Merknad" + "Scheme" "Skjema" + "Summary" "Samandrag" + "Table" "Tabell" + "Tableau" "Tablå" + "Theorem" "Teorem" +End + +Translation pl + "Acknowledgement" "Podziękowanie" + "Algorithm" "Algorytm" + "Axiom" "Aksjomat" + "Case" "Przypadek" + "Claim" "Stwierdzenie" + "Conclusion" "Konkluzja" + "Condition" "Warunek" + "Conjecture" "Hipoteza" + "Corollary" "Wniosek" + "Criterion" "Kryterium" + "Definition" "Definicja" + "Example" "Przykład" + "Exercise" "Ćwiczenie" + "Fact" "Fakt" + "Figure" "Rysunek" + "Lemma" "Lemat" + "List of Algorithms" "Lista algorytmów" + "List of Figures" "Spis rysunków" + "List of Tables" "Spis tabel" + "Notation" "Notacja" + "Note" "Notka" + "Proof" "Dowód" + "Proposition" "Propozycja" + "Question" "Pytanie" + "Remark" "Uwaga" + "Summary" "Podsumowanie" + "Table" "Tabela" + "Theorem" "Twierdzenie" +End + +Translation pt + "Acknowledgement" "Agradecimento" + "Algorithm" "Algoritmo" + "Assumption" "Assumpção" + "Axiom" "Axioma" + "Case" "Caso" + "Claim" "Afirmação" + "Conclusion" "Conclusão" + "Condition" "Condição" + "Conjecture" "Conjectura" + "Corollary" "Corolário" + "Criterion" "Critério" + "Definition" "Definição" + "Example" "Exemplo" + "Exercise" "Exercício" + "Fact" "Facto" + "Figure" "Figura" + "Graph" "Gráfico" + "Lemma" "Lema" + "List of Algorithms" "Lista de Algoritmos" + "List of Figures" "Lista de Figuras" + "List of Graphs" "Lista de Gráficos" + "List of Tableaux" "Lista de Quadros" + "List of Tables" "Lista de Tabelas" + "Notation" "Notação" + "Note" "Nota" + "Problem" "Problema" + "Proof" "Prova" + "Proposition" "Proposição" + "Question" "Questão" + "Remark" "Observação" + "Summary" "Sumário" + "Table" "Tabela" + "Tableau" "Quadro" + "Theorem" "Teorema" +End + +Translation ro + "Algorithm" "Algoritm" + "Assumption" "Supoziţie" + "Axiom" "Axiomă" + "Case" "Caz" + "Chart" "Tabel" + "Claim" "Declaraţie" + "Conclusion" "Concluzie" + "Condition" "Condiţie" + "Conjecture" "Conjectură" + "Corollary" "Corolar" + "Criterion" "Criteriu" + "Definition" "Definiţie" + "Example" "Exemplu" + "Exercise" "Exerciţiu" + "Fact" "Fapt" + "Figure" "Figură" + "Graph" "Grafic" + "Lemma" "Lemă" + "List of Algorithms" "Listă de Algoritmi" + "List of Charts" "Listă de Tabele" + "List of Figures" "Listă de figuri" + "List of Graphs" "Listă de grafice" + "List of Schemes" "Listă de Scheme" + "List of Tableaux" "Listă de Tabele" + "List of Tables" "Listă de tabele" + "Notation" "Notaţie" + "Note" "Notă" + "Plate" "Tăbliţă" + "Problem" "Problemă" + "Proof" "Demonstraţie" + "Proposition" "Propoziţie" + "Question" "Întrebare" + "Remark" "Remarcă" + "Scheme" "Schemă" + "Summary" "Sumar" + "Table" "Tabel" + "Tableau" "Tabel" + "Theorem" "Teoremă" +End + +Translation ru + "Acknowledgement" "Благодарность" + "Algorithm" "Алгоритм" + "Assumption" "Допущение" + "Axiom" "Аксиома" + "Case" "Вариант" + "Chart" "Чертеж" + "Claim" "Утверждение" + "Conclusion" "Заключение" + "Condition" "Условие" + "Conjecture" "Предположение" + "Corollary" "Вывод" + "Criterion" "Критерий" + "Definition" "Определение" + "Example" "Пример" + "Exercise" "Упражнение" + "Fact" "Факт" + "Figure" "Рисунок" + "Graph" "График" + "Lemma" "Лемма" + "List of Algorithms" "Список алгоритмов" + "List of Charts" "Список чертежей" + "List of Figures" "Список рисунков" + "List of Graphs" "Список графиков" + "List of Schemes" "Список схем" + "List of Tables" "Список таблиц" + "Notation" "Нотация" + "Note" "Заметка" + "Problem" "Проблема" + "Proof" "Доказательство" + "Proposition" "Предложение" + "Question" "Вопрос" + "Remark" "Замечание" + "Scheme" "Схема" + "Summary" "Сводка" + "Table" "Таблица" + "Theorem" "Теорема" +End + +Translation sk + "Acknowledgement" "Poďakovania" + "Algorithm" "Algoritmus" + "Assumption" "Predpoklad" + "Axiom" "Axióma" + "Case" "Prípad" + "Chart" "Nákres" + "Claim" "Nárok" + "Conclusion" "Záver" + "Condition" "Podmienka" + "Conjecture" "Dohad" + "Criterion" "Kritérium" + "Definition" "Definícia" + "Example" "Príklad" + "Exercise" "Úloha" + "Fact" "Fakt" + "Figure" "Obrázok" + "Graph" "Grafika" + "List of Algorithms" "Zoznam algoritmov" + "List of Charts" "Zoznam nákresov" + "List of Figures" "Zoznam obrázkov" + "List of Graphs" "Zoznam grafík" + "List of Schemes" "Zoznam náčrtkov" + "List of Tableaux" "Zoznam tablov" + "List of Tables" "Zoznam tabuliek" + "MarginFigure" "OkrajnýObrázok" + "MarginTable" "Okrajná tabuľka" + "Notation" "Notácia" + "Note" "Poznámka" + "Problem" "Problém" + "Proof" "Dôkaz" + "Proposition" "Tvrdenie" + "Question" "Otázka" + "Remark" "Pripomienka" + "Scheme" "Náčrtok" + "Summary" "Súhrn" + "Table" "Tabuľka" + "Tableau" "Tablo" + "Theorem" "Teoréma" +End + +Translation sl + "Acknowledgement" "Priznanje" + "Algorithm" "Algoritem" + "Axiom" "Aksiom" + "Case" "Primer" + "Claim" "Trditev" + "Conclusion" "Sklep" + "Condition" "Pogoj" + "Conjecture" "Domneva" + "Corollary" "Korolar" + "Criterion" "Kriterij" + "Definition" "Definicija" + "Example" "Zgled" + "Exercise" "Vaja" + "Fact" "Dejstvo" + "Figure" "Slika" + "Lemma" "Lema" + "Notation" "Zapis" + "Note" "Opomba" + "Proof" "Dokaz" + "Proposition" "Podmena" + "Question" "Vprašanje" + "Remark" "Pripomba" + "Summary" "Povzetek" + "Table" "Tabela" + "Theorem" "Izrek" +End + +Translation sr + "Acknowledgement" "Zahvalnost" + "Algorithm" "Algoritam" + "Assumption" "Pretpostavka" + "Axiom" "Aksiom" + "Claim" "Tvrdnja" + "Conclusion" "Zaključak" + "Condition" "Uslov" + "Conjecture" "Pretpostavka" + "Corollary" "Posledica" + "Definition" "Definicija" + "Example" "Primer" + "Exercise" "Vežba" + "Fact" "Činjenica" + "List of Algorithms" "Spisak algoritama" + "List of Schemes" "Lista Šema" + "Notation" "Zabeleška" + "Note" "Napomena" + "Proof" "Dokaz" + "Proposition" "Predlog" + "Question" "Pitanje" + "Remark" "Napomena" + "Scheme" "Šema" + "Summary" "Rezime" + "Theorem" "Teorema" +End + +Translation sv + "Acknowledgement" "Erkännande" + "Algorithm" "Algoritm" + "Assumption" "Antagande" + "Case" "Fall" + "Chart" "Diagram" + "Claim" "Påstående" + "Conclusion" "Slutsats" + "Condition" "Villkor" + "Conjecture" "Förmodan" + "Corollary" "Korollarium" + "Criterion" "Kriterium" + "Example" "Exempel" + "Exercise" "Övning" + "Fact" "Fakta" + "Figure" "Figur" + "Graph" "Graf" + "List of Algorithms" "Lista över algoritmer" + "List of Charts" "Lista över diagram" + "List of Figures" "Lista över figurer" + "List of Graphs" "Lista över grafer" + "List of Schemes" "Lista över scheman" + "List of Tableaux" "Lista över tablåer" + "List of Tables" "Lista över tabeller" + "MarginFigure" "Marginalfigur" + "MarginTable" "Marginaltabell" + "Note" "Not" + "Planotable" "Planotabell" + "Plate" "Platta" + "Proof" "Bevis" + "Question" "Fråga" + "Remark" "Anmärkning" + "Scheme" "Schema" + "Summary" "Sammanfattning" + "Table" "Tabell" + "Tableau" "Tablå" + "Theorem" "Teorem" +End + +Translation tr + "Acknowledgement" "Teşekkür" + "Algorithm" "Algoritma" + "Assumption" "Varsayım" + "Axiom" "Aksiyom" + "Case" "Durum" + "Claim" "İddia" + "Conclusion" "Sonuç" + "Condition" "Koşul" + "Conjecture" "Varsayım" + "Corollary" "Doğal Sonuç" + "Criterion" "Kriter" + "Definition" "Tanım" + "Example" "Örnek" + "Exercise" "Alıştırma" + "Fact" "Olgu" + "Figure" "Figür" + "List of Algorithms" "Algoritma Listesi" + "List of Figures" "Figür Listesi" + "List of Schemes" "Plan Listesi" + "List of Tableaux" "Tablo Listesi" + "List of Tables" "Tablo Listesi" + "Notation" "Notasyon" + "Note" "Not" + "Proof" "İspat" + "Proposition" "Önerme" + "Question" "Soru" + "Remark" "Açıklama" + "Scheme" "Plan" + "Summary" "Özet" + "Table" "Tablo" + "Tableau" "Tablo" + "Theorem" "Teorem" +End + +Translation uk + "Acknowledgement" "Подяка" + "Algorithm" "Алгоритм" + "Assumption" "Припущення" + "Axiom" "Аксіома" + "Case" "Варіант" + "Chart" "Діаграма" + "Claim" "Твердження" + "Conclusion" "Висновки" + "Condition" "Умова" + "Conjecture" "Припущення" + "Corollary" "Наслідок" + "Criterion" "Критерій" + "Definition" "Визначення" + "Example" "Приклад" + "Exercise" "Вправа" + "Fact" "Факт" + "Figure" "Рисунок" + "Graph" "Графік" + "Lemma" "Лема" + "List of Algorithms" "Алгоритм" + "List of Charts" "Список діаграм" + "List of Figures" "Список малюнків" + "List of Graphs" "Список графіків" + "List of Schemes" "Список схем" + "List of Tableaux" "Список табло" + "List of Tables" "Список таблиць" + "Notation" "Позначення" + "Note" "Примітка" + "Problem" "Проблема" + "Proof" "На коректуру" + "Proposition" "Твердження" + "Question" "Питання" + "Remark" "Помітка" + "Summary" "Зведення" + "Table" "Таблиця" + "Tableau" "Табло" + "Theorem" "Теорема" +End + +Translation zh_CN + "Acknowledgement" "致谢" + "Algorithm" "算法" + "Chart" "图表" + "Conclusion" "结论" + "Condition" "条件" + "Conjecture" "猜想" + "Definition" "定义" + "Example" "示例" + "Exercise" "练习" + "Figure" "图" + "Graph" "图形" + "Lemma" "引理" + "List of Algorithms" "算法列表" + "List of Charts" "图表列表" + "List of Figures" "图像列表" + "List of Graphs" "图形列表" + "List of Tables" "表格列表" + "Note" "备忘" + "Problem" "问题" + "Proof" "证明" + "Proposition" "Propositio" + "Question" "问题" + "Summary" "摘要" + "Table" "表" + "Theorem" "定理" +End + +Translation zh_TW + "Acknowledgement" "致謝" + "Algorithm" "演算法" + "Assumption" "假定" + "Case" "大小寫" + "Claim" "宣稱" + "Conclusion" "結論" + "Condition" "條件" + "Criterion" "條件" + "Definition" "定義" + "Example" "範例" + "Exercise" "練習" + "Figure" "圖片" + "List of Algorithms" "演算法清單" + "List of Figures" "圓圈清單" + "List of Tables" "表格列表" + "Notation" "記法" + "Note" "註記" + "Problem" "問題" + "Proof" "證明" + "Question" "問題" + "Remark" "備註" + "Summary" "概要" + "Table" "表格" + "Theorem" "定理" +End diff --git a/po/Rules-lyx b/po/Rules-lyx index 4c853320f7..8aefa41eb2 100644 --- a/po/Rules-lyx +++ b/po/Rules-lyx @@ -30,6 +30,11 @@ layouts_l10n.pot: $(top_srcdir)/lib/layouts/*.layout $(top_srcdir)/lib/layouts/* LC_ALL=C ; export LC_ALL ; \ python $(srcdir)/lyx_pot.py -b $(top_srcdir) -o $@ -t layouts ${top_srcdir}/lib/layouts/*.layout ${top_srcdir}/lib/layouts/*.inc ${top_srcdir}/lib/layouts/*.module +$(top_srcdir)/lib/layouttranslations: $(POFILES) $(top_srcdir)/lib/layouts/*.layout \ + $(top_srcdir)/lib/layouts/*.inc $(top_srcdir)/lib/layouts/*.module + LC_ALL=C ; export LC_ALL ; \ + python $(srcdir)/lyx_pot.py -b $(top_srcdir) -o $@ -t layouttranslations ${top_srcdir}/lib/layouts/*.layout ${top_srcdir}/lib/layouts/*.inc ${top_srcdir}/lib/layouts/*.module + languages_l10n.pot: $(top_srcdir)/lib/languages python $(srcdir)/lyx_pot.py -b $(top_srcdir) -o $@ -t languages ${top_srcdir}/lib/languages diff --git a/po/lyx_pot.py b/po/lyx_pot.py index a6637a5617..3ac835d409 100755 --- a/po/lyx_pot.py +++ b/po/lyx_pot.py @@ -17,6 +17,8 @@ # to output in gettext .pot format. # import sys, os, re, getopt +if sys.version_info < (2, 4, 0): + from sets import Set as set def relativePath(path, base): '''return relative path from top source dir''' @@ -74,7 +76,7 @@ def ui_l10n(input_files, output, base): output.close() -def layouts_l10n(input_files, output, base): +def layouts_l10n(input_files, output, base, layouttranslations): '''Generate pot file from lib/layouts/*.{layout,inc,module}''' out = open(output, 'w') Style = re.compile(r'^Style\s+(.*)', re.IGNORECASE) @@ -95,11 +97,26 @@ def layouts_l10n(input_files, output, base): CounterFormat = re.compile(r'\s*PrettyFormat\s+"?(.*)"?') CiteFormat = re.compile(r'\s*CiteFormat') KeyVal = re.compile(r'^\s*_\w+\s+(.*)$') + Float = re.compile(r'\s*Float') End = re.compile(r'\s*End') + Comment = re.compile(r'\s*#') + + languages = [] + keyset = set() + if layouttranslations: + linguas_file = os.path.join(base, 'po/LINGUAS') + for line in open(linguas_file).readlines(): + if Comment.search(line) == None: + languages.extend(line.split()) + # walon is not a known document language + # FIXME: Do not hardcode, read from lib/languages! + if 'wa' in languages: + languages.remove('wa') for src in input_files: readingDescription = False readingI18nPreamble = False + readingFloat = False readingCiteFormats = False descStartLine = -1 descLines = [] @@ -111,7 +128,8 @@ def layouts_l10n(input_files, output, base): if res != None: readingDescription = False desc = " ".join(descLines) - writeString(out, src, base, lineno + 1, desc) + if not layouttranslations: + writeString(out, src, base, lineno + 1, desc) continue descLines.append(line[1:].strip()) continue @@ -128,7 +146,10 @@ def layouts_l10n(input_files, output, base): res = I18nString.search(line) if res != None: string = res.group(1) - writeString(out, src, base, lineno, string) + if layouttranslations: + keyset.add(string) + else: + writeString(out, src, base, lineno, string) continue res = I18nPreamble.search(line) if res != None: @@ -137,66 +158,126 @@ def layouts_l10n(input_files, output, base): res = NameRE.search(line) if res != None: string = res.group(1) - writeString(out, src, base, lineno + 1, string) + if not layouttranslations: + writeString(out, src, base, lineno + 1, string) continue res = Style.search(line) if res != None: string = res.group(1) string = string.replace('_', ' ') - writeString(out, src, base, lineno, string) + if not layouttranslations: + writeString(out, src, base, lineno, string) continue res = LabelString.search(line) if res != None: string = res.group(1) - writeString(out, src, base, lineno, string) + if not layouttranslations: + writeString(out, src, base, lineno, string) continue res = GuiName.search(line) if res != None: string = res.group(1) - writeString(out, src, base, lineno, string) + if layouttranslations: + # gui name must only be added for floats + if readingFloat: + keyset.add(string) + else: + writeString(out, src, base, lineno, string) continue res = CategoryName.search(line) if res != None: string = res.group(1) - writeString(out, src, base, lineno, string) + if not layouttranslations: + writeString(out, src, base, lineno, string) continue res = ListName.search(line) if res != None: string = res.group(1) - writeString(out, src, base, lineno, string) + if layouttranslations: + keyset.add(string.strip('"')) + else: + writeString(out, src, base, lineno, string) continue res = InsetLayout.search(line) if res != None: string = res.group(1) string = string.replace('_', ' ') #Flex:xxx is not used in translation - #writeString(out, src, base, lineno, string) + #if not layouttranslations: + # writeString(out, src, base, lineno, string) m = FlexCheck.search(string) if m: - writeString(out, src, base, lineno, m.group(1)) + if not layouttranslations: + writeString(out, src, base, lineno, m.group(1)) continue res = Category.search(line) if res != None: string = res.group(1) - writeString(out, src, base, lineno, string) + if not layouttranslations: + writeString(out, src, base, lineno, string) continue res = CounterFormat.search(line) if res != None: string = res.group(1) - writeString(out, src, base, lineno, string) + if not layouttranslations: + writeString(out, src, base, lineno, string) + continue + res = Float.search(line) + if res != None: + readingFloat = True continue res = CiteFormat.search(line) if res != None: readingCiteFormats = True res = End.search(line) - if res != None and readingCiteFormats: + if res != None: readingCiteFormats = False + readingFloat = False if readingCiteFormats: res = KeyVal.search(line) if res != None: val = res.group(1) - writeString(out, src, base, lineno, val) - + if not layouttranslations: + writeString(out, src, base, lineno, val) + + if layouttranslations: + # Extract translations of layout files + import polib + + # Sort languages and key to minimize the diff between different runs + # with changed translations + languages.sort() + keys = [] + for key in keyset: + keys.append(key) + keys.sort() + + print >> out, '''# This file has been automatically generated by po/lyx_pot.py. +# PLEASE DO NOT MODIFY ANYTHING HERE! If you want to regenerate this file +# from the translations, run `make ../lib/layouttranslations' in po.''' + for lang in languages: + print >> out, '\nTranslation %s' % lang + poname = os.path.join(base, 'po/' + lang + '.po') + po = polib.pofile(poname) + # Iterate through po entries and not keys for speed reasons. + # FIXME: The code is still too slow + trans = dict() + for entry in po: + if not entry.translated(): + continue + if entry.msgid in keys: + key = entry.msgid.replace('\\', '\\\\').replace('"', '\\"') + val = entry.msgstr.replace('\\', '\\\\').replace('"', '\\"') + # some translators keep untranslated entries + if val != key: + trans[key] = val + for key in keys: + if key in trans.keys(): + val = trans[key] + print >> out, '\t"%s" "%s"' % \ + (key.encode('utf-8'), val.encode('utf-8')) + print >> out, 'End' + out.close() @@ -364,6 +445,7 @@ where --input_type can be ui: lib/ui/* layouts: lib/layouts/* + layouttranslations: create lib/layouttranslations from po/*.po and lib/layouts/* qt4: qt4 ui files languages: file lib/languages encodings: file lib/encodings @@ -392,7 +474,7 @@ if __name__ == '__main__': elif opt in ['-s', '--src_file']: input_files = [f.strip() for f in open(value)] - if input_type not in ['ui', 'layouts', 'modules', 'qt4', 'languages', 'encodings', 'external', 'formats'] or output is None: + if input_type not in ['ui', 'layouts', 'layouttranslations', 'qt4', 'languages', 'encodings', 'external', 'formats'] or output is None: print 'Wrong input type or output filename.' sys.exit(1) @@ -401,7 +483,9 @@ if __name__ == '__main__': if input_type == 'ui': ui_l10n(input_files, output, base) elif input_type == 'layouts': - layouts_l10n(input_files, output, base) + layouts_l10n(input_files, output, base, False) + elif input_type == 'layouttranslations': + layouts_l10n(input_files, output, base, True) elif input_type == 'qt4': qt4_l10n(input_files, output, base) elif input_type == 'external': diff --git a/src/LaTeXFeatures.cpp b/src/LaTeXFeatures.cpp index 90809577a0..a714df386e 100644 --- a/src/LaTeXFeatures.cpp +++ b/src/LaTeXFeatures.cpp @@ -1202,8 +1202,7 @@ docstring const LaTeXFeatures::getTClassI18nPreamble(bool use_babel, bool use_po continue; docstring const type = from_ascii(fl.floattype()); docstring const flname = from_utf8(fl.name()); - docstring name = translateIfPossible(flname, - buffer().language()->code()); + docstring name = buffer().language()->translateLayout(fl.name()); // only request translation if we have a real translation // (that differs from the source) if (use_polyglossia && flname != name) diff --git a/src/Language.cpp b/src/Language.cpp index e588218047..33b7303df1 100644 --- a/src/Language.cpp +++ b/src/Language.cpp @@ -21,6 +21,7 @@ #include "support/debug.h" #include "support/FileName.h" +#include "support/filetools.h" #include "support/lstrings.h" #include "support/Messages.h" @@ -39,6 +40,25 @@ Language const * latex_language = &latex_lang; Language const * reset_language = 0; +docstring const Language::translateLayout(string const & m) const +{ + if (m.empty()) + return docstring(); + + if (!isAscii(m)) { + lyxerr << "Warning: not translating `" << m + << "' because it is not pure ASCII.\n"; + return from_utf8(m); + } + + TranslationMap::const_iterator it = layoutTranslations_.find(m); + if (it != layoutTranslations_.end()) + return it->second; + + return from_ascii(m); +} + + bool Language::readLanguage(Lexer & lex) { enum LanguageTags { @@ -173,6 +193,31 @@ bool Language::read(Lexer & lex) return true; } + +bool Language::readLayoutTranslations(Lexer & lex) +{ + layoutTranslations_.clear(); + while (lex.isOK()) { + if (lex.checkFor("End")) + break; + if (!lex.next(true)) + return false; + string const key = lex.getString(); + if (!lex.next(true)) + return false; + docstring const val = lex.getDocString(); + layoutTranslations_[key] = val; + } + return true; +} + + +void Language::readLayoutTranslations(Language const & lang) +{ + layoutTranslations_ = lang.layoutTranslations_; +} + + void Languages::read(FileName const & filename) { Lexer lex; @@ -212,6 +257,61 @@ void Languages::read(FileName const & filename) default_language = &(*languagelist.begin()).second; LYXERR0("Using \"" << default_language->lang() << "\" instead!"); } + + // Read layout translations + FileName const path = libFileSearch(string(), "layouttranslations"); + readLayoutTranslations(path); +} + + +void Languages::readLayoutTranslations(support::FileName const & filename) +{ + Lexer lex; + lex.setFile(filename); + lex.setContext("Languages::read"); + while (lex.isOK()) { + if (!lex.checkFor("Translation")) { + if (lex.isOK()) + lex.printError("Unknown layout translation tag `$$Token'"); + break; + } + if (!lex.next(true)) + break; + string const code = lex.getString(); + // we need to mimic gettext: code can be a two-letter code, + // which should match all variants, e.g. "de" should match + // "de_DE", "de_AT" etc. + Language * firstlang = 0; + LanguageList::iterator const end = languagelist.end(); + for (LanguageList::iterator it = languagelist.begin(); it != end; ++it) { + // special case for chinese: + // simplified => code == "zh_CN", langcode == "zh_CN" + // traditional => code == "zh_TW", langcode == "zh_CN" + string const langcode = it->second.code(); + string const name = it->second.lang(); + if ((code == langcode && name != "chinese-traditional") || + (code == "zh_TW" && name == "chinese-traditional") || + (code.size() == 2 && langcode.size() > 2 && + code + '_' == langcode.substr(0, 3))) { + if (firstlang) + it->second.readLayoutTranslations(*firstlang); + else { + if (!it->second.readLayoutTranslations(lex)) { + lex.printError("Could not read " + "layout translations " + "for language `" + + code + "'"); + break; + } + firstlang = &(it->second); + } + } + } + if (!firstlang) { + lex.printError("Unknown language `" + code + "'"); + break; + } + } } diff --git a/src/Language.h b/src/Language.h index 073ecdb6d4..828fd3e420 100644 --- a/src/Language.h +++ b/src/Language.h @@ -15,8 +15,9 @@ #ifndef LANGUAGE_H #define LANGUAGE_H +#include "support/docstring.h" + #include -#include namespace lyx { @@ -45,6 +46,13 @@ public: bool rightToLeft() const { return rightToLeft_; } /// Is an (at least partial) translation of this language available? bool translated() const { return translated_; } + /** + * Translate a string from the layout files that appears in the output. + * It takes the translations from lib/layouttranslations instead of + * the .mo files. This should be used for every translation that + * appears in the exported document, since the output must not depend + * on installed locales. Non-ASCII keys are not translated. */ + docstring const translateLayout(std::string const & msg) const; /// default encoding Encoding const * encoding() const { return encoding_; } /// @@ -69,6 +77,10 @@ public: bool read(Lexer & lex); /// bool readLanguage(Lexer & lex); + /// + bool readLayoutTranslations(Lexer & lex); + /// + void readLayoutTranslations(Language const & lang); // for the use in std::map friend bool operator<(Language const & p, Language const & q); private: @@ -102,6 +114,10 @@ private: bool as_babel_options_; /// bool translated_; + /// + typedef std::map TranslationMap; + /// + TranslationMap layoutTranslations_; }; @@ -123,6 +139,8 @@ public: /// void read(support::FileName const & filename); /// + void readLayoutTranslations(support::FileName const & filename); + /// Language const * getLanguage(std::string const & language) const; /// size_type size() const { return languagelist.size(); } diff --git a/src/Layout.cpp b/src/Layout.cpp index 7dc41e4810..76893029cd 100644 --- a/src/Layout.cpp +++ b/src/Layout.cpp @@ -897,14 +897,7 @@ docstring const i18npreamble(Language const * lang, docstring const & templ, boo smatch sub; while (regex_search(preamble, sub, reg)) { string const key = sub.str(1); - string translated; - if (isAscii(key)) - translated = to_utf8(getMessages(lang->code()).get(key)); - else { - lyxerr << "Warning: not translating `" << key - << "' because it is not pure ASCII." << endl; - translated = key; - } + string translated = to_utf8(lang->translateLayout(key)); preamble = subst(preamble, sub.str(), translated); } #endif