diff options
author | Thomas Voss <mail@thomasvoss.com> | 2024-09-21 11:01:17 +0200 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2024-09-21 11:01:17 +0200 |
commit | 4962f21fbba949ae11638af5fd7292fe07ef94f1 (patch) | |
tree | bff5b048fb58259cce37f04595279964bd169a8c | |
parent | 42d0c8cc527dd0732b8a752116d676fd1863bb15 (diff) |
Support collapsing whitespace in translations
-rw-r--r-- | cmd/exttmpl/main.go | 33 | ||||
-rw-r--r-- | src/rosetta/bg/messages.gotext.json | 4 | ||||
-rw-r--r-- | src/rosetta/el/messages.gotext.json | 4 | ||||
-rw-r--r-- | src/rosetta/en/messages.gotext.json | 6 | ||||
-rw-r--r-- | src/rosetta/nl/messages.gotext.json | 4 | ||||
-rw-r--r-- | src/templates/404.html.tmpl | 7 | ||||
-rw-r--r-- | src/templates/about.html.tmpl | 24 | ||||
-rw-r--r-- | src/templates/coins-mintages.html.tmpl | 23 | ||||
-rw-r--r-- | src/templates/coins.html.tmpl | 5 | ||||
-rw-r--r-- | src/templates/error.html.tmpl | 13 | ||||
-rw-r--r-- | src/templates/index.html.tmpl | 8 | ||||
-rw-r--r-- | src/templates/jargon.html.tmpl | 72 |
12 files changed, 170 insertions, 33 deletions
diff --git a/cmd/exttmpl/main.go b/cmd/exttmpl/main.go index ca7c15f..599879a 100644 --- a/cmd/exttmpl/main.go +++ b/cmd/exttmpl/main.go @@ -5,6 +5,7 @@ import ( "os" "path/filepath" "slices" + "strings" "text/template/parse" "golang.org/x/text/language" @@ -120,12 +121,11 @@ func process(tmplMsgs *[]pipeline.Message, node parse.Node) { continue } if sn, ok := arg.(*parse.StringNode); ok { + txt := collapse(sn.Text) *tmplMsgs = append(*tmplMsgs, pipeline.Message{ - ID: pipeline.IDList{sn.Text}, - Key: sn.Text, - Message: pipeline.Text{ - Msg: sn.Text, - }, + ID: pipeline.IDList{txt}, + Key: txt, + Message: pipeline.Text{Msg: txt}, }) } } @@ -177,6 +177,29 @@ func languages() []language.Tag { return tags } +func collapse(s string) string { + var ( + sb strings.Builder + prev bool + ) + const spc = " \t\n" + + for _, ch := range strings.Trim(s, spc) { + if strings.ContainsRune(spc, ch) { + if prev { + continue + } + ch = ' ' + prev = true + } else { + prev = false + } + sb.WriteRune(ch) + } + + return sb.String() +} + func try(err error) { if err != nil { die(err) diff --git a/src/rosetta/bg/messages.gotext.json b/src/rosetta/bg/messages.gotext.json index ddc5a15..ec9e7c3 100644 --- a/src/rosetta/bg/messages.gotext.json +++ b/src/rosetta/bg/messages.gotext.json @@ -382,8 +382,8 @@ "translation": "" }, { - "id": "NIFC coins are coins minted without the intention of being put into general circulation. These coins are typically minted with the purpose of being put into coincards or coin-sets to be sold to collectors. Occasionally they are also handed out to collectors for face value at banks.", - "message": "NIFC coins are coins minted without the intention of being put into general circulation. These coins are typically minted with the purpose of being put into coincards or coin-sets to be sold to collectors. Occasionally they are also handed out to collectors for face value at banks.", + "id": "NIFC coins are coins minted without the intention of being put into general circulation. These coins are typically minted with the purpose of being put into coincards or coin-sets to be sold to collectors. Occasionally they are also handed out to collectors for face value at banks.", + "message": "NIFC coins are coins minted without the intention of being put into general circulation. These coins are typically minted with the purpose of being put into coincards or coin-sets to be sold to collectors. Occasionally they are also handed out to collectors for face value at banks.", "translation": "" }, { diff --git a/src/rosetta/el/messages.gotext.json b/src/rosetta/el/messages.gotext.json index 7ad824f..f3e85e3 100644 --- a/src/rosetta/el/messages.gotext.json +++ b/src/rosetta/el/messages.gotext.json @@ -382,8 +382,8 @@ "translation": "" }, { - "id": "NIFC coins are coins minted without the intention of being put into general circulation. These coins are typically minted with the purpose of being put into coincards or coin-sets to be sold to collectors. Occasionally they are also handed out to collectors for face value at banks.", - "message": "NIFC coins are coins minted without the intention of being put into general circulation. These coins are typically minted with the purpose of being put into coincards or coin-sets to be sold to collectors. Occasionally they are also handed out to collectors for face value at banks.", + "id": "NIFC coins are coins minted without the intention of being put into general circulation. These coins are typically minted with the purpose of being put into coincards or coin-sets to be sold to collectors. Occasionally they are also handed out to collectors for face value at banks.", + "message": "NIFC coins are coins minted without the intention of being put into general circulation. These coins are typically minted with the purpose of being put into coincards or coin-sets to be sold to collectors. Occasionally they are also handed out to collectors for face value at banks.", "translation": "" }, { diff --git a/src/rosetta/en/messages.gotext.json b/src/rosetta/en/messages.gotext.json index 28df4ad..a0c5986 100644 --- a/src/rosetta/en/messages.gotext.json +++ b/src/rosetta/en/messages.gotext.json @@ -534,9 +534,9 @@ "fuzzy": true }, { - "id": "NIFC coins are coins minted without the intention of being put into general circulation. These coins are typically minted with the purpose of being put into coincards or coin-sets to be sold to collectors. Occasionally they are also handed out to collectors for face value at banks.", - "message": "NIFC coins are coins minted without the intention of being put into general circulation. These coins are typically minted with the purpose of being put into coincards or coin-sets to be sold to collectors. Occasionally they are also handed out to collectors for face value at banks.", - "translation": "NIFC coins are coins minted without the intention of being put into general circulation. These coins are typically minted with the purpose of being put into coincards or coin-sets to be sold to collectors. Occasionally they are also handed out to collectors for face value at banks.", + "id": "NIFC coins are coins minted without the intention of being put into general circulation. These coins are typically minted with the purpose of being put into coincards or coin-sets to be sold to collectors. Occasionally they are also handed out to collectors for face value at banks.", + "message": "NIFC coins are coins minted without the intention of being put into general circulation. These coins are typically minted with the purpose of being put into coincards or coin-sets to be sold to collectors. Occasionally they are also handed out to collectors for face value at banks.", + "translation": "NIFC coins are coins minted without the intention of being put into general circulation. These coins are typically minted with the purpose of being put into coincards or coin-sets to be sold to collectors. Occasionally they are also handed out to collectors for face value at banks.", "translatorComment": "Copied from source.", "fuzzy": true }, diff --git a/src/rosetta/nl/messages.gotext.json b/src/rosetta/nl/messages.gotext.json index 07a2ea1..0ddb8d9 100644 --- a/src/rosetta/nl/messages.gotext.json +++ b/src/rosetta/nl/messages.gotext.json @@ -382,8 +382,8 @@ "translation": "" }, { - "id": "NIFC coins are coins minted without the intention of being put into general circulation. These coins are typically minted with the purpose of being put into coincards or coin-sets to be sold to collectors. Occasionally they are also handed out to collectors for face value at banks.", - "message": "NIFC coins are coins minted without the intention of being put into general circulation. These coins are typically minted with the purpose of being put into coincards or coin-sets to be sold to collectors. Occasionally they are also handed out to collectors for face value at banks.", + "id": "NIFC coins are coins minted without the intention of being put into general circulation. These coins are typically minted with the purpose of being put into coincards or coin-sets to be sold to collectors. Occasionally they are also handed out to collectors for face value at banks.", + "message": "NIFC coins are coins minted without the intention of being put into general circulation. These coins are typically minted with the purpose of being put into coincards or coin-sets to be sold to collectors. Occasionally they are also handed out to collectors for face value at banks.", "translation": "" }, { diff --git a/src/templates/404.html.tmpl b/src/templates/404.html.tmpl index 3771a0f..c86dc30 100644 --- a/src/templates/404.html.tmpl +++ b/src/templates/404.html.tmpl @@ -5,7 +5,12 @@ </header> <main> <p> - {{ .T "The page you were looking for does not exist. If you believe this is a mistake then don’t hesitate to contact @onetruemangoman on Discord or email us at %s." `<a href="mailto:mail@euro-cash.eu">mail@euro-cash.eu</a>` | safe }} + {{ .T ` + The page you were looking for does not exist. If you believe this + is a mistake then don’t hesitate to contact @onetruemangoman on + Discord or email us at %s.` + `<a href="mailto:mail@euro-cash.eu">mail@euro-cash.eu</a>` | safe + }} </p> </main> {{ end }} diff --git a/src/templates/about.html.tmpl b/src/templates/about.html.tmpl index aed356a..ba5aaaa 100644 --- a/src/templates/about.html.tmpl +++ b/src/templates/about.html.tmpl @@ -6,11 +6,31 @@ <main> <h2>{{ .T "Open Source" }}</h2> <p> - {{ .T "This website is an open project, and a collaboration between developers, translators, and researchers. All source code, data, images, and more for the website are open source and can be found %shere%s. This site is licensed under the BSD 0-Clause license giving you the full freedom to do whatever you would like with anyof the content on this site." `<a href="https://git.thomasvoss.com/www.euro-cash.eu" target="_blank">` `</a>` | safe }} + {{ .T ` + This website is an open project, and a collaboration between + developers, translators, and researchers. All source code, data, + images, and more for the website are open source and can be found + %shere%s. This site is licensed under the BSD 0-Clause license + giving you the full freedom to do whatever you would like with + anyof the content on this site.` + `<a href="https://git.thomasvoss.com/www.euro-cash.eu" + target="_blank">` + `</a>` | safe + }} </p> <h2>{{ .T "Contact Us" }}</h2> <p> - {{ .T "While we try to stay as up-to-date as possible and to fact check our information, it is always possible that we get something wrong, lack a translation, or are missing some piece of data you may have. In such a case don’t hesitate to contact us; we’ll try to get the site updated or fixed as soon as possible. You are always free to contribute via a git patch if you are more technically included, but if not you can always send an email to %s or contact ‘@onetruemangoman’ on Discord." `<a href="mailto:mail@euro-cash.eu">mail@euro-cash.eu</a>` | safe }} + {{ .T ` + While we try to stay as up-to-date as possible and to fact check + our information, it is always possible that we get something wrong, + lack a translation, or are missing some piece of data you may + have. In such a case don’t hesitate to contact us; we’ll try to get + the site updated or fixed as soon as possible. You are always free + to contribute via a git patch if you are more technically included, + but if not you can always send an email to %s or contact + ‘@onetruemangoman’ on Discord.` + `<a href="mailto:mail@euro-cash.eu">mail@euro-cash.eu</a>` | safe + }} </p> <h2>{{ .T "Special Thanks" }}</h2> <table> diff --git a/src/templates/coins-mintages.html.tmpl b/src/templates/coins-mintages.html.tmpl index d6c743b..b410e6e 100644 --- a/src/templates/coins-mintages.html.tmpl +++ b/src/templates/coins-mintages.html.tmpl @@ -5,17 +5,34 @@ </header> <main> <p> - {{ .T "Here you’ll be able to view all the known mintages for all coins. You’ll also be able to filter on country, denomination, etc. If you have any mintage data that’s missing from our site, feel free to contact us." }} + {{ .T ` + Here you’ll be able to view all the known mintages for all + coins. You’ll also be able to filter on country, denomination, + etc. If you have any mintage data that’s missing from our site, + feel free to contact us. + ` }} </p> <hr /> {{ if eq .Code "nl" }} <h2>{{ .T "Additional Notes" }}</h2> <ul> <li> - {{ .T "Most coins from the years 2003–2016 are listed as NIFC coins while other popular sources such as Numista claim they were minted for circulation. For more information on why others are wrong, %sclick here%s." `<a href="#TODO">` `</a>` | safe }} + {{ .T ` + Most coins from the years 2003–2016 are listed as NIFC coins + while other popular sources such as Numista claim they were + minted for circulation. For more information on why others are + wrong, %sclick here%s.` + `<a href="#TODO">` `</a>` | safe + }} </li> <li> - {{ .T "In 2003 Numista calculated a total of %d coins issued for coin sets per denomination. Our own calculations found only %d. Numista also forgot to include the many hundred thousand coins from the coin roll sets that were produced." 217503 177003 }} + {{ .T ` + In 2003 Numista calculated a total of %d coins issued for coin + sets per denomination. Our own calculations found only + %d. Numista also forgot to include the many hundred thousand + coins from the coin roll sets that were produced.` + 217503 177003 + }} </li> </ul> {{ end }} diff --git a/src/templates/coins.html.tmpl b/src/templates/coins.html.tmpl index d231ed5..68c3f87 100644 --- a/src/templates/coins.html.tmpl +++ b/src/templates/coins.html.tmpl @@ -5,7 +5,10 @@ </header> <main> <p> - {{ .T "On this section of the site you can find everything there is to know about the coins of the Eurozone." }} + {{ .T ` + On this section of the site you can find everything there is to + know about the coins of the Eurozone. + ` }} </p> <hr /> <section> diff --git a/src/templates/error.html.tmpl b/src/templates/error.html.tmpl index 28ef0a3..47bff81 100644 --- a/src/templates/error.html.tmpl +++ b/src/templates/error.html.tmpl @@ -5,10 +5,19 @@ </header> <main> <p> - {{ .T "If you’re seeing this page, it means that something went wrong on our end that we need to fix. Our team has been notified of this error, and we apologise for the inconvenience." }} + {{ .T ` + If you’re seeing this page, it means that something went wrong on + our end that we need to fix. Our team has been notified of this + error, and we apologise for the inconvenience. + ` }} </p> <p> - {{ .T "If this issue persists, don’t hesitate to contact @onetruemangoman on Discord or to email us at %s." `<a href="https://git.thomasvoss.com/www.euro-cash.eu" target="_blank">` | safe }} + {{ .T ` + If this issue persists, don’t hesitate to contact @onetruemangoman + on Discord or to email us at %s.` + `<a href="https://git.thomasvoss.com/www.euro-cash.eu" + target="_blank">` | safe + }} </p> </main> {{ end }} diff --git a/src/templates/index.html.tmpl b/src/templates/index.html.tmpl index 9a26046..fafd0ee 100644 --- a/src/templates/index.html.tmpl +++ b/src/templates/index.html.tmpl @@ -12,7 +12,13 @@ </header> <main> <p> - {{ .T "Welcome to the Euro Cash Compendium. This sites aims to be a resource for you to discover everything there is to know about the coins and banknotes of the Euro, a currency that spans 26 countries and 350 million people. We also have dedicated sections of the site for collectors." }} + {{ .T ` + Welcome to the Euro Cash Compendium. This sites aims to be a + resource for you to discover everything there is to know about the + coins and banknotes of the Euro, a currency that spans 26 countries + and 350 million people. We also have dedicated sections of the site + for collectors. + ` }} </p> </main> {{ end }} diff --git a/src/templates/jargon.html.tmpl b/src/templates/jargon.html.tmpl index a952103..200db8b 100644 --- a/src/templates/jargon.html.tmpl +++ b/src/templates/jargon.html.tmpl @@ -5,10 +5,20 @@ </header> <main> <p> - {{ .T "Both on this website and in other euro-cash-related forums there are many terms you will come across that you may not immediately understand. This page will hopefully get you up to speed with the most important and frequently-used terminology." }} + {{ .T ` + Both on this website and in other euro-cash-related forums there + are many terms you will come across that you may not immediately + understand. This page will hopefully get you up to speed with the + most important and frequently-used terminology. + ` }} </p> <p> - {{ .T "All terms defined below can be used as clickable links which highlight the selected term. It is recommended to use these links when sharing this page with others, so that the relevant terms are highlighted." }} + {{ .T ` + All terms defined below can be used as clickable links which + highlight the selected term. It is recommended to use these links + when sharing this page with others, so that the relevant terms are + highlighted. + ` }} </p> <hr/> <h2>{{ .T "General Terms" }}</h2> @@ -16,34 +26,78 @@ {{ template "jargon/dt" (tuple "nifc" (.T "NIFC — Not Intended For Circulation")) }} <dd> <p> - {{ .T "NIFC coins are coins minted without the intention of being put into general circulation. These coins are typically minted with the purpose of being put into coincards or coin-sets to be sold to collectors. Occasionally they are also handed out to collectors for face value at banks." }} + {{ .T ` + NIFC coins are coins minted without the intention of being put + into general circulation. These coins are typically minted with + the purpose of being put into coincards or coin-sets to be sold + to collectors. Occasionally they are also handed out to + collectors for face value at banks. + ` }} </p> <p> - {{ .T "While uncommon, NIFC coins are occasionally found in circulation. This can happen for a variety of reasons such as someone depositing their coin collection (known as a ‘collection dump’), or a collector’s child spending their rare coins on an ice cream. Some coin mints have also been known to put NIFC coins that have gone unsold for multiple years into circulation." }} + {{ .T ` + While uncommon, NIFC coins are occasionally found in + circulation. This can happen for a variety of reasons such as + someone depositing their coin collection (known as a + ‘collection dump’), or a collector’s child spending their rare + coins on an ice cream. Some coin mints have also been known to + put NIFC coins that have gone unsold for multiple years into + circulation. + ` }} </p> </dd> {{ template "jargon/dt" (tuple "au" (.T "AU — Almost Uncirculated")) }} <dd> - {{ .T "AU coins are coins that are in extremely good condition as a result of limited use in circulation. Unlike the term ‘UNC’, this term is a description of the coins quality, not its usage. AU coins often appear to retain most of their original luster as well as possessing little-to-no scratches or other forms of post-mint damage (PMD)." }} + {{ .T ` + AU coins are coins that are in extremely good condition as a + result of limited use in circulation. Unlike the term ‘UNC’, this + term is a description of the coins quality, not its usage. AU + coins often appear to retain most of their original luster as + well as possessing little-to-no scratches or other forms of + post-mint damage (PMD). + ` }} </dd> {{ template "jargon/dt" (tuple "bu" (.T "BU — Brilliantly Uncirculated")) }} <dd> - {{ .T "BU is a general term to refer to coins from coincards and -sets. These are different from UNC coins in that they are typically handled with more care during the minting process and are struck with higher-quality dies than the coins minted for coin rolls resulting in a higher-quality end product. You may also see these coins referred to by the French term ‘fleur de coin’." }} + {{ .T ` + BU is a general term to refer to coins from coincards and + -sets. These are different from UNC coins in that they are + typically handled with more care during the minting process and + are struck with higher-quality dies than the coins minted for + coin rolls resulting in a higher-quality end product. You may + also see these coins referred to by the French term ‘fleur de + coin’. + ` }} </dd> {{ template "jargon/dt" (tuple "pmd" (.T "PMD — Post-Mint Damage")) }} <dd> - {{ .T "Post-mint damage is any damage that a coin has sustained outside of the minting process, such as through being dropped on the ground, hit against a table, etc." }} + {{ .T ` + Post-mint damage is any damage that a coin has sustained outside + of the minting process, such as through being dropped on the + ground, hit against a table, etc. + ` }} </dd> {{ template "jargon/dt" (tuple "unc" (.T "UNC — Uncirculated")) }} <dd> - {{ .T "Uncirculated coins are coins that have never been used in a monetary exchange. The term ‘UNC’ is often mistakenly used to refer to coins in very good condition, but this is incorrect. A coin in poor condition that has never been circulated is still considered an ‘UNC’ coin." }} + {{ .T ` + Uncirculated coins are coins that have never been used in a + monetary exchange. The term ‘UNC’ is often mistakenly used to + refer to coins in very good condition, but this is incorrect. A + coin in poor condition that has never been circulated is still + considered an ‘UNC’ coin. + ` }} </dd> </dl> <h2>{{ .T "Collector-Specific Terms" }}</h2> <dl> {{ template "jargon/dt" (tuple "crh" (.T "CRH — Coin Roll Hunting")) }} <dd> - {{ .T "Coin roll hunting is a general term for the activity of searching through coin rolls and -bags to find coins for a collection. Coin rolls and bags are often obtained at banks or coin roll machines." }} + {{ .T ` + Coin roll hunting is a general term for the activity of searching + through coin rolls and -bags to find coins for a collection. Coin + rolls and bags are often obtained at banks or coin roll + machines. + ` }} </dd> </dl> </main> |