diff --git a/include/lang/ca.rem b/include/lang/ca.rem index 04661cc8..b9afd6d3 100644 --- a/include/lang/ca.rem +++ b/include/lang/ca.rem @@ -51,3 +51,5 @@ FSET subst_hours(h) iif(h==1, "1 hora", h + " hores") SET $Is "és" SET $Was "va ser" SET $And "i" + +TRANSLATE "LANGID" "ca" diff --git a/include/lang/da.rem b/include/lang/da.rem index 4c7ed4c4..f198dcbf 100644 --- a/include/lang/da.rem +++ b/include/lang/da.rem @@ -67,3 +67,5 @@ FSET subst_hx(alt, d, t) "den " + zeropad(day(d), 2) + $DateSep + zeropad(monnum FSET subst_ix(alt, d, t) "den " + zeropad(monnum(d), 2) + $DateSep + zeropad(day(d), 2) FSET subst_ux(alt, d, t) subst_ax(alt, d, t) FSET subst_vx(alt, d, t) subst_gx(alt, d, t) + +TRANSLATE "LANGID" "da" diff --git a/include/lang/de.rem b/include/lang/de.rem index 7b13ccee..f5fd527b 100644 --- a/include/lang/de.rem +++ b/include/lang/de.rem @@ -64,28 +64,13 @@ FSET subst_p(alt, d, t) iif(d == today()+1, "", "en") # Localization of various astronomical events -# Perihelion -SET earthseasons_Perihelion_str "Perihel" +TRANSLATE "Perihelion" "Perihel" +TRANSLATE "Vernal Equinox" "Frühlingsanfang" +TRANSLATE "Summer Solstice" "Sommeranfang" +TRANSLATE "Aphelion" "Aphel" +TRANSLATE "Autumnal Equinox" "Herbstanfang" +TRANSLATE "Winter Solstice" "Winteranfang" +TRANSLATE "Daylight Saving Time Starts" "Beginn Sommerzeit" +TRANSLATE "Daylight Saving Time Ends" "Ende Sommerzeit" -# Vernal equinox -SET earthseasons_EquinoxMar_str "Frühlingsanfang" - -# Summer solstice -SET earthseasons_SolsticeJun_str "Sommeranfang" - -# Aphelion -SET earthseasons_Aphelion_str "Aphel" - -# Autumnal Equinox -SET earthseasons_EquinoxSep_str "Herbstanfang" - -# Winter Solstice -SET earthseasons_SolsticeDec_str "Winteranfang" - -# Daylight saving time starts -SET daylightST_starts_str "Beginn Sommerzeit" - -# Daylight saving time ends -SET daylightST_ends_str "Ende Sommerzeit" - -PRESERVE earthseasons_Perihelion_str earthseasons_EquinoxMar_str earthseasons_SolsticeJun_str earthseasons_Aphelion_str earthseasons_EquinoxSep_str earthseasons_SolsticeDec_str daylightST_starts_str daylightST_ends_str \ No newline at end of file +TRANSLATE "LANGID" "de" diff --git a/include/lang/es.rem b/include/lang/es.rem index d4c22c66..897c7f13 100644 --- a/include/lang/es.rem +++ b/include/lang/es.rem @@ -46,3 +46,5 @@ SET $Hplu "s" SET $Mplu "s" FSET subst_bx(a, d, t) "dentro de " + (d-today()) + " días" + +TRANSLATE "LANGID" "es" diff --git a/include/lang/fi.rem b/include/lang/fi.rem index 6cced002..1bdde4d5 100644 --- a/include/lang/fi.rem +++ b/include/lang/fi.rem @@ -93,6 +93,8 @@ FSET subst_min_past(m) iif(m==0, "", m + " " + $Minute + iif(m==1, " ", $Mplu + FSET subst_hour_future(h) iif(h==0, "", h + " tunnin ") FSET subst_min_future(m) iif(m==0, "", m + " minuutin ") +TRANSLATE "LANGID" "fi" + TRANSLATE "Missing ']'" "Puuttuva ']'" TRANSLATE "Missing quote" "Puuttuva lainausmerkki" TRANSLATE "Expression too complex" "Liian monimutkainen lauseke" diff --git a/include/lang/fr.rem b/include/lang/fr.rem index a6bdbb6e..e00185d7 100644 --- a/include/lang/fr.rem +++ b/include/lang/fr.rem @@ -61,6 +61,7 @@ FSET subst_jx(alt, date, time) iif(alt, subst_j_alt(date), $On + " " + subst_j_a FSET subst_k_alt(date) wkday(date) + ", " + day(date) + subst_ordinal(day(date)) + " " + mon(date) FSET subst_kx(alt, date, time) iif(alt, subst_k_alt(date), $On + " " + subst_k_alt(date)) +TRANSLATE "LANGID" "fr" TRANSLATE "Missing ']'" "']' manquant" TRANSLATE "Missing quote" "Apostrophe manquant" diff --git a/include/lang/gr.rem b/include/lang/gr.rem index d82edf23..434529b8 100644 --- a/include/lang/gr.rem +++ b/include/lang/gr.rem @@ -56,30 +56,13 @@ FSET subst_gx(alt, d, t) iif(alt, subst_g_alt(d), $On + " " + subst_g_alt(d)) FSET subst_ux(alt, d, t) subst_ax(alt, d, t) FSET subst_vx(alt, d, t) subst_gx(alt, d, t) -# Localization of various astronomical events +TRANSLATE "LANGID" "gr" -# Perihelion -SET earthseasons_Perihelion_str "Περιήλιον" - -# Vernal equinox -SET earthseasons_EquinoxMar_str "Εαρινή ισημερία" - -# Summer solstice -SET earthseasons_SolsticeJun_str "Θερινό ηλιοστάσιο" - -# Aphelion -SET earthseasons_Aphelion_str "Αφήλιον" - -# Autumnal Equinox -SET earthseasons_EquinoxSep_str "Φθινοπωρινή ισημερία" - -# Winter Solstice -SET earthseasons_SolsticeDec_str "Χειμερινό ηλιοστάσιο" - -# Daylight saving time starts -SET daylightST_starts_str "Έναρξη θέρους" - -# Daylight saving time ends -SET daylightST_ends_str "Τέλος θέρους" - -PRESERVE earthseasons_Perihelion_str earthseasons_EquinoxMar_str earthseasons_SolsticeJun_str earthseasons_Aphelion_str earthseasons_EquinoxSep_str earthseasons_SolsticeDec_str daylightST_starts_str daylightST_ends_str +TRANSLATE "Perihelion" "Περιήλιον" +TRANSLATE "Vernal Equinox" "Εαρινή ισημερία" +TRANSLATE "Summer Solstice" "Θερινό ηλιοστάσιο" +TRANSLATE "Aphelion" "Αφήλιον" +TRANSLATE "Autumnal Equinox" "Φθινοπωρινή ισημερία" +TRANSLATE "Winter Solstice" "Χειμερινό ηλιοστάσιο" +TRANSLATE "Daylight Saving Time Starts" "Έναρξη θέρους" +TRANSLATE "Daylight Saving Time Ends" "Τέλος θέρους" diff --git a/include/lang/is.rem b/include/lang/is.rem index ed5e367b..420a290b 100644 --- a/include/lang/is.rem +++ b/include/lang/is.rem @@ -49,3 +49,5 @@ SET $Mplu "r" FSET subst_bx(a, d, t) "eftir " + (d - today()) + " daga" fset subst_p(a, d, t) iif(d == today()+1, "", "a") + +TRANSLATE "LANGID" "is" diff --git a/include/lang/it.rem b/include/lang/it.rem index e17b4317..901f3089 100644 --- a/include/lang/it.rem +++ b/include/lang/it.rem @@ -65,3 +65,5 @@ FSET subst_hours(h) iif(h==1, "1 ora", h + " ore") FSET subst_0(a, d, t) iif(abs(now()-t)/60==1, "a", "e") FSET subst_9(a, d, t) iif(abs(now()-t)%60==1, "o", "i") + +TRANSLATE "LANGID" "it" diff --git a/include/lang/nl.rem b/include/lang/nl.rem index 1837ec3e..486b0f97 100644 --- a/include/lang/nl.rem +++ b/include/lang/nl.rem @@ -55,6 +55,8 @@ FSET subst_hours(h) iif(h==1, "1 uur", h + " uren") FSET subst_bx(a, d, t) "over " + (d-today()) + " dagen" +TRANSLATE "LANGID" "nl" + TRANSLATE "New Moon" "Nieuwe maan" TRANSLATE "First Quarter" "Eerste kwartier" TRANSLATE "Full Moon" "Volle maan" diff --git a/include/lang/no.rem b/include/lang/no.rem index d6e6abfc..cdae168d 100644 --- a/include/lang/no.rem +++ b/include/lang/no.rem @@ -56,3 +56,6 @@ FSET subst_g_alt(d) wkday(d) + ", den " + day(d) + ". " + mon(d) FSET subst_ux(a, d, t) subst_ax(a, d, t) FSET subst_vx(a, d, t) subst_gx(a, d, t) FSET subst_p(a, d, t) iif(d==today()+1, "", "er") + +TRANSLATE "LANGID" "no" + diff --git a/include/lang/pl.rem b/include/lang/pl.rem index 52bfa032..d9295d59 100644 --- a/include/lang/pl.rem +++ b/include/lang/pl.rem @@ -68,6 +68,8 @@ FSET subst_1past(diff) iif(diff/60==0, subst_1min(diff%60), diff%60==0, subst_1h FSET subst_1min(m) m + " " + $Minute + subst_pl_plu(m) FSET subst_1h(h) h + " " + $Hour + subst_pl_plu(h) +TRANSLATE "LANGID" "pl" + TRANSLATE "Ok" "OK" TRANSLATE "Missing ']'" "Brakujący ']'" TRANSLATE "Missing quote" "Brakujący nawias" diff --git a/include/lang/pt.rem b/include/lang/pt.rem index 3f0ee5cb..0f377f3c 100644 --- a/include/lang/pt.rem +++ b/include/lang/pt.rem @@ -68,6 +68,8 @@ FSET subst_1help(diff) iif(diff/60==0, subst_mplu(diff%60), diff%60==0, subst_hp FSET subst_mplu(m) iif(m==1, "1 " + $Minute, m + " " + $Minute + $Mplu) FSET subst_hplu(h) iif(h==1, "1 " + $Hour, h + " " + $Hour + $Hplu) +TRANSLATE "LANGID" "pt" + TRANSLATE "Missing ']'" "Falta um ']'" TRANSLATE "Missing quote" "Falta uma aspa" TRANSLATE "Expression too complex" "Expressao muito complexa" diff --git a/include/lang/ro.rem b/include/lang/ro.rem index 704b51e3..bcbfce7f 100644 --- a/include/lang/ro.rem +++ b/include/lang/ro.rem @@ -66,3 +66,5 @@ FSET subst_1helper(diff, when) when + iif(diff%60==0, subst_1h(diff/60), diff/60 FSET subst_1h(h) iif(h==1, "1 oră", h + " ore") FSET subst_1m(m) iif(m==1, "1 minut", m + " minute") FSET subst_0(a, d, t) iif(abs(t-now())/60==1, "ă", "e") + +TRANSLATE "LANGID" "ro" diff --git a/man/remind.1.in b/man/remind.1.in index 04227aee..f6077f12 100644 --- a/man/remind.1.in +++ b/man/remind.1.in @@ -5714,6 +5714,18 @@ system variables \fIexcept for\fR \fB$Hplu\fR and \fB$Mplu\fR. .PP The converse does not apply; creating a translation table entry for "December" does not automatically set \fB$December\fR. +.PP +The translation table always contains a special entry \fBLANGID\fR whose +default value is \fBen\fR. Translators are encouraged to add a \fBLANGID\fR +entry in their language files. For example, if you write a translation +file for the Dutch language, add this line: +.PP +.nf + TRANSLATE "LANGID" "nl" +.fi +.PP +Scripts can use \fB_("LANGID")\fR to query the translation language that is +in effect. .SH LANGUAGE PACKS .PP \fBRemind\fR ships with a number of language packs, which are simply reminder diff --git a/src/trans.c b/src/trans.c index 9e2a522a..d1eca56a 100644 --- a/src/trans.c +++ b/src/trans.c @@ -195,6 +195,7 @@ InitTranslationTable(void) fprintf(stderr, "Unable to initialize translation hash table: Out of memory. Exiting.\n"); exit(1); } + InsertTranslation("LANGID", "en"); } static XlateItem * @@ -286,6 +287,9 @@ DoTranslate(ParsePtr p) if (item) { RemoveTranslation(item); } + if (!strcmp(DBufValue(&orig), "LANGID")) { + InsertTranslation("LANGID", "en"); + } r = OK; } DBufFree(&orig); diff --git a/tests/test.cmp b/tests/test.cmp index 7eaab25f..41472285 100644 --- a/tests/test.cmp +++ b/tests/test.cmp @@ -5980,10 +5980,12 @@ _("Hello") => "Hallo!!!!!" TRANSLATE DUMP # Translation table +TRANSLATE "LANGID" "en" TRANSLATE "Hello" "Hallo!!!!!" TRANSLATE CLEAR TRANSLATE DUMP # Translation table +TRANSLATE "LANGID" "en" set a _("Hello") _("Hello") => "Hello" @@ -5994,6 +5996,18 @@ TRANSLATE "Quux" "OOOGHY" # Delete Bar translation TRANSLATE "Bar" +# LANGID is a special case +set a _("LANGID") +_("LANGID") => "en" + +TRANSLATE "LANGID" "nl" +set a _("LANGID") +_("LANGID") => "nl" + +TRANSLATE "LANGID" +set a _("LANGID") +_("LANGID") => "en" + set a _("Wookie") _("Wookie") => "Bar" set a _("Bar") @@ -6038,6 +6052,7 @@ TRANSLATE DUMP # Translation table TRANSLATE "Wookie" "Bar" TRANSLATE "Friday" "TxFriday" +TRANSLATE "LANGID" "en" TRANSLATE "Monday" "TxMonday" TRANSLATE "Tuesday" "TxTuesday" TRANSLATE "at" "Txat" @@ -6073,14 +6088,15 @@ TRANSLATE "May" "TxMay" TRANSLATE "Saturday" "TxSaturday" TRANSLATE "missing quote" "missing a quote -../tests/test.rem(1247): Missing quote +../tests/test.rem(1256): Missing quote TRANSLATE "missing quote -../tests/test.rem(1248): Missing quote +../tests/test.rem(1257): Missing quote DO torture-test.rem # Turn off some debugging to make output a bit easier on the eyes... DEBUG -xte # Translation table +TRANSLATE "LANGID" "en" TRANSLATE "We" "Survived" Dedup-0 Dedup-1 @@ -16082,12 +16098,12 @@ Dedup-9996 Dedup-9997 Dedup-9998 Dedup-9999 -../tests/test.rem(1253): `/': Ya tried to divide by zero, ya FOOOL!!!!! -../tests/test.rem(1255): `/': Division by zero +../tests/test.rem(1262): `/': Ya tried to divide by zero, ya FOOOL!!!!! +../tests/test.rem(1264): `/': Division by zero Var hash: total = 100141; maxlen = 5; avglen = 1.142 Func hash: total = 100016; maxlen = 5; avglen = 1.140 Dedup hash: total = 10000; maxlen = 7; avglen = 1.828 -Trans hash: total = 1; maxlen = 1; avglen = 0.059 +Trans hash: total = 2; maxlen = 1; avglen = 0.118 Expression nodes allocated: 300096 Expression nodes high-water: 300073 Expression nodes leaked: 0 @@ -23542,7 +23558,7 @@ No reminders. Var hash: total = 1; maxlen = 1; avglen = 0.059 Func hash: total = 0; maxlen = 0; avglen = 0.000 Dedup hash: total = 0; maxlen = 0; avglen = 0.000 -Trans hash: total = 0; maxlen = 0; avglen = 0.000 +Trans hash: total = 1; maxlen = 1; avglen = 0.059 Expression nodes allocated: 512 Expression nodes high-water: 499 Expression nodes leaked: 0 @@ -24068,7 +24084,7 @@ No reminders. Var hash: total = 1; maxlen = 1; avglen = 0.059 Func hash: total = 1; maxlen = 1; avglen = 0.059 Dedup hash: total = 0; maxlen = 0; avglen = 0.000 -Trans hash: total = 1; maxlen = 1; avglen = 0.059 +Trans hash: total = 2; maxlen = 1; avglen = 0.118 Expression nodes allocated: 300032 Expression nodes high-water: 300000 Expression nodes leaked: 0 diff --git a/tests/test.rem b/tests/test.rem index 57809cdd..f9cddc02 100644 --- a/tests/test.rem +++ b/tests/test.rem @@ -1205,6 +1205,15 @@ TRANSLATE "Quux" "OOOGHY" # Delete Bar translation TRANSLATE "Bar" +# LANGID is a special case +set a _("LANGID") + +TRANSLATE "LANGID" "nl" +set a _("LANGID") + +TRANSLATE "LANGID" +set a _("LANGID") + set a _("Wookie") set a _("Bar") set a _("Quux")