Add 4th parameter for Dutch, etc

This commit is contained in:
Will Bradley 2023-08-31 18:29:44 -07:00
parent bb649e8a1d
commit 9bf4a6091e
Signed by: will
GPG Key ID: 1159B930701263F3

View File

@ -206,12 +206,13 @@
<div id="fmtModalDesc" class="form-text">
Formatter strings use numbered variables like <span class="badge bg-secondary">%1$s</span> to indicate parts that should be replaced by other text.
<ul>
<li><span class="badge text-bg-warning">%1$s</span> will be replaced by the distance, like "in 500 meters."</li>
<li><span class="badge text-bg-primary">%2$s</span> will be replaced by the direction, like "make a right turn."</li>
<li><span class="badge text-bg-secondary">%3$s</span> will be replaced by the name or number of the street or exit, like "Main Street" or "Exit 123."</li>
<li><span class="badge text-bg-warning">%1$s</span> will be replaced by the distance translation string, like "in 500 meters."</li>
<li><span class="badge text-bg-primary">%2$s</span> will be replaced by the direction translation string, like "make a right turn." <i>For languages that use different grammar for sentences like "in 100 feet, make a right turn onto Main Street" versus "in 100 feet, make a right turn" an optional string like <code>make_a_right_turn_street</code> can replace the default <code>make_a_right_turn</code> string.</i></li>
<li><span class="badge text-bg-secondary">%3$s</span> will be dynamically replaced by the name or number of the street or exit, like "Main Street" or "Exit 123."</li>
<li><span class="badge text-bg-danger">%4$s</span> is optional and is used for languages that split their grammar for sentences like "in 100 feet, make a right turn onto Main Street" into two parts, like "make in 100 feet a right turn onto Main Street". Optional strings like <code>make_a_right_turn_street_verb</code> may be defined for this purpose.</li>
</ul>
For example "<span class="badge text-bg-warning">%1$s</span> <span class="badge text-bg-primary">%2$s</span> onto <span class="badge text-bg-secondary">%3$s</span>"<br/> becomes "<span class="badge text-bg-warning">In 500 meters</span> <span class="badge text-bg-primary">make a right turn</span> onto <span class="badge text-bg-secondary">Main Street</span>"<br/><br/>
whereas "<span class="badge text-bg-secondary">%3$s</span> is the place to <span class="badge text-bg-primary">%2$s</span> when you reach it <span class="badge text-bg-warning">%1$s</span>"<br/> becomes "<span class="badge text-bg-secondary">Main Street</span> is the place to <span class="badge text-bg-primary">make a right turn</span> when you reach it <span class="badge text-bg-warning">in 500 meters</span>."
whereas "<span class="badge text-bg-danger">%4$s</span> onto <span class="badge text-bg-secondary">%3$s</span> a <span class="badge text-bg-primary">%2$s</span> when you reach it <span class="badge text-bg-warning">%1$s</span>"<br/> can become "<span class="badge text-bg-danger">Make</span> onto <span class="badge text-bg-secondary">Main Street</span> a <span class="badge text-bg-primary">right turn</span> when you reach it <span class="badge text-bg-warning">in 500 meters</span>." with the help of <code>_street</code> and <code>_street_verb</code> strings.
</div>
</div>
<div class="modal-footer">
@ -256,12 +257,15 @@
function buildTranStringInput(key, value, color="text-bg-primary", editable=true) {
var classes = "stringTxt";
if (!value)
return "";
var size = value.length+2;
var english = "";
var english = "key: "+key;
var englishVersion = window.originalEnglishData[key];
if (englishVersion) {
english = "en: "+englishVersion;
english += "\nen: "+englishVersion;
}
var out = "<span class='tranString badge "+color+"'><input type='text' class='"+classes+"' size='"+size+"' readonly data-key='"+
@ -572,7 +576,9 @@
if (dir != "destination") {
// can't "arrive onto" your destination
// TODO: this gets duplicated in the fmtModalForm handler
//
// TODO: this entire section gets largely duplicated in the fmtModalForm handler
//
var fmtObj = {
dir: dir,
dist: dist,
@ -580,7 +586,7 @@
};
var fmtKey = btoa(JSON.stringify(fmtObj));
window.fmtSoundData[fmtKey] = fmtObj;
var ttsFmt = buildFmtStringInput('dist_direction_onto_street', data['dist_direction_onto_street'], "text-bg-dark", fmtKey);
var streetFmt = buildFmtStringInput('dist_direction_onto_street', data['dist_direction_onto_street'], "text-bg-dark", fmtKey);
var streetDir;
// overwrite the direction string if present for street TTS
@ -590,12 +596,17 @@
streetDir = buildTranStringInput(dir, data[dir]);
}
ttsFmt = ttsFmt.replace("%1$s", buildTranStringInput(dist, data[dist], "text-bg-warning"));
ttsFmt = ttsFmt.replace("%2$s", streetDir);
ttsFmt = ttsFmt.replace("%3$s", buildTranStringInput("", nextStreets[(i+1) % nextStreets.length], "text-bg-secondary", false)); // non-editable
var streetDirVerb;
if (data[dir+"_street_verb"])
streetDirVerb = data[dir+"_street_verb"];
streetFmt = streetFmt.replace("%1$s", buildTranStringInput(dist, data[dist], "text-bg-warning"));
streetFmt = streetFmt.replace("%2$s", streetDir);
streetFmt = streetFmt.replace("%3$s", buildTranStringInput("", nextStreets[(i+1) % nextStreets.length], "text-bg-secondary", false)); // non-editable
streetFmt = streetFmt.replace("%4$s", buildTranStringInput(dir+"_street_verb", streetDirVerb, "text-bg-danger")); //optional
$("#out-e").append(inputPre +
ttsFmt +
streetFmt +
inputPost);
}
});
@ -608,7 +619,9 @@
// can't "arrive onto" your destination
var nextDir = direction[(i + 1) % direction.length];
// TODO: this gets duplicated in the fmtModalForm handler
//
// TODO: this entire section gets largely duplicated in the fmtModalForm handler
//
var fmtObj = {
dir: dir,
dist: dist,
@ -616,7 +629,7 @@
};
var fmtKey = btoa(JSON.stringify(fmtObj));
window.fmtSoundData[fmtKey] = fmtObj;
var ttsFmt = buildFmtStringInput('dist_direction_onto_street', data['dist_direction_onto_street'], "text-bg-dark", fmtKey);
var streetFmt = buildFmtStringInput('dist_direction_onto_street', data['dist_direction_onto_street'], "text-bg-dark", fmtKey);
var streetDir;
// overwrite the direction string if present for street TTS
@ -626,12 +639,17 @@
streetDir = buildTranStringInput(dir, data[dir]);
}
ttsFmt = ttsFmt.replace("%1$s", buildTranStringInput(dist, data[dist], "text-bg-warning"));
ttsFmt = ttsFmt.replace("%2$s", streetDir);
ttsFmt = ttsFmt.replace("%3$s", buildTranStringInput("", nextStreets[(i+1) % nextStreets.length], "text-bg-secondary", false)); // non-editable
var streetDirVerb;
if (data[dir+"_street_verb"])
streetDirVerb = data[dir+"_street_verb"];
streetFmt = streetFmt.replace("%1$s", buildTranStringInput(dist, data[dist], "text-bg-warning"));
streetFmt = streetFmt.replace("%2$s", streetDir);
streetFmt = streetFmt.replace("%3$s", buildTranStringInput("", nextStreets[(i+1) % nextStreets.length], "text-bg-secondary", false)); // non-editable
streetFmt = streetFmt.replace("%4$s", buildTranStringInput(dir+"_street_verb", streetDirVerb, "text-bg-danger")); //optional
$("#out-f").append(inputPre +
ttsFmt +
streetFmt +
buildTranStringInput('then', data['then'], "text-bg-success") +
buildTranStringInput(nextDir, data[nextDir], "text-bg-primary") +
inputPost);
@ -679,7 +697,9 @@
var dist = fmtObj.dist;
var nextStr = fmtObj.nextStr;
// TODO: this gets duplicated in the showData function
//
// TODO: this entire section gets largely duplicated in the showData function
//
var streetFmt = buildFmtStringInput('dist_direction_onto_street', window.modifiedSoundData['dist_direction_onto_street'], "text-bg-dark", fmtKey);
var streetDir;
@ -690,9 +710,14 @@
streetDir = buildTranStringInput(dir, window.modifiedSoundData[dir]);
}
var streetDirVerb;
if (window.modifiedSoundData[dir+"_street_verb"])
streetDirVerb = window.modifiedSoundData[dir+"_street_verb"];
streetFmt = streetFmt.replace("%1$s", buildTranStringInput(dist, window.modifiedSoundData[dist], "text-bg-warning")); // no full stops
streetFmt = streetFmt.replace("%2$s", streetDir); // no full stops
streetFmt = streetFmt.replace("%3$s", buildTranStringInput("", nextStreets[nextStr], "text-bg-secondary", false)); // non-editable
streetFmt = streetFmt.replace("%4$s", buildTranStringInput(dir+"_street_verb", streetDirVerb, "text-bg-danger")); //optional
$(o).parent().parent().html(streetFmt);
});
@ -712,7 +737,7 @@
}
function loadLocale(){
var commitHash = "b7138ae7f7f7f78da042edc8496d012ad4058334";
var commitHash = "9d26c555c24895597fa4328221c60639f5222c9f";
var sourceUrl = "https://raw.githubusercontent.com/organicmaps/organicmaps/"+commitHash+"/data/strings/sound.txt";
$("#sourceUrl").attr("href", sourceUrl).text("sound.txt");