[openstreetmap-website] Routing directions mentioning that roads are unnamed (#904)
mmd
notifications at github.com
Wed Jul 8 19:05:09 UTC 2015
Thanks, I'm getting your point. I don't seem to find a way in the [I18n lib](https://github.com/fnando/i18n-js/blob/master/app/assets/javascripts/i18n.js) to deal with missing variable names. I can only think about some crazy workarounds like the following (not tested) or even checking for `%{name}` in `I18n.t(TURN_INSTRUCTIONS[instCodes[0]]`. Maybe others have some better ideas to ease the transition phase without causing lots of work.
```Javascript
var name = s[1] ? "<b>" + s[1] + "</b>" : I18n.t('javascripts.directions.instructions.unnamed');
if (instCodes[0] === "11" && instCodes[1]) {
instText += I18n.t('javascripts.directions.instructions.roundabout_with_exit', { exit: instCodes[1], name: name } );
} else {
var transl1 = I18n.t(TURN_INSTRUCTIONS[instCodes[0]], { name: name });
var transl2 = I18n.t(TURN_INSTRUCTIONS[instCodes[0]]);
if (transl1 === transl2) { // fallback to legacy mode where name variable is missing
instText += transl2 + " " + name;
}
else
instText += transl1;
}
```
---
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/issues/904#issuecomment-119698247
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20150708/8b7f08c5/attachment.html>
More information about the rails-dev
mailing list