Translator comments to have empty translation spots
This commit is contained in:
@@ -21,12 +21,14 @@ import kotlin.io.path.useDirectoryEntries
|
||||
|
||||
class Translator private constructor(private val iso: String) {
|
||||
|
||||
fun translate(enText: String) = translations[iso]?.get(enText) ?: enText.also {
|
||||
reportMissingTranslation(enText)
|
||||
}
|
||||
fun translate(enText: String) =
|
||||
translations[iso]?.get(enText) ?: enText.let {
|
||||
it.replace(Regex("_BLANK_\\w+"), "")
|
||||
}.also {
|
||||
reportMissingTranslation(enText)
|
||||
}
|
||||
|
||||
fun translate(uri: String, template: Template): Template? {
|
||||
if (iso == "en") return template
|
||||
val key = Pair(uri, iso)
|
||||
var translated = translatedTemplates[key]
|
||||
if (translated != null && translated.lastModified < template.lastModified) {
|
||||
@@ -39,7 +41,11 @@ class Translator private constructor(private val iso: String) {
|
||||
if (translated == null) {
|
||||
translated = template.clone() as Template
|
||||
val data: SimpleNode = translated!!.data as SimpleNode
|
||||
translateNode(data)
|
||||
if (iso == "en") {
|
||||
stripComments(data)
|
||||
} else {
|
||||
translateNode(data)
|
||||
}
|
||||
translatedTemplates[key] = translated!!
|
||||
}
|
||||
}
|
||||
@@ -47,6 +53,15 @@ class Translator private constructor(private val iso: String) {
|
||||
return translated
|
||||
}
|
||||
|
||||
private fun stripComments(node: SimpleNode) {
|
||||
if (node is ASTText) {
|
||||
node.text = node.text.replace(Regex("_BLANK_\\w+"), "")
|
||||
}
|
||||
else for (i in 0 until node.jjtGetNumChildren()) {
|
||||
stripComments(node.jjtGetChild(i) as SimpleNode)
|
||||
}
|
||||
}
|
||||
|
||||
private fun translateNode(node: SimpleNode, ignoringInput: String? = null): String? {
|
||||
var ignoring = ignoringInput
|
||||
if (node is ASTText) translateFragments(node.text, ignoring).let {
|
||||
|
@@ -281,7 +281,7 @@
|
||||
Advanced parameters
|
||||
</div>
|
||||
<div class="popup-content">
|
||||
#parse('tour-parameters.inc.html')
|
||||
#translate('tour-parameters.inc.html')
|
||||
</div>
|
||||
<div class="popup-footer">
|
||||
<div class="form-actions">
|
||||
|
@@ -112,6 +112,7 @@
|
||||
#set($rankThreshold = $tour.pairing.secondary.rankThreshold)
|
||||
#levels($rankThreshold)
|
||||
</select>
|
||||
_BLANK_AFTER_RANK_THRESHOLD_
|
||||
</label>
|
||||
<label>
|
||||
• <input name="winsThreshold" type="checkbox" class="inline" value="true" #if($tour.pairing.secondary.winsThreshold) checked #end/>
|
||||
|
@@ -101,7 +101,7 @@
|
||||
</div>
|
||||
<div class="popup-content">
|
||||
#if($round < $tour.rounds)
|
||||
<div class="warning">Warning: publishing partial results at round <span>$round</span> out of <span>$tour.rounds</span>!</div>
|
||||
<div class="warning">Warning: publishing partial results at round <span>$round</span> / <span>$tour.rounds</span>!</div>
|
||||
#end
|
||||
<form class="ui edit form">
|
||||
<div class="field">
|
||||
|
Reference in New Issue
Block a user