Hi Felix

Could there be a command like {set name='${mkgmap:trans:name}' }
That way one could build a map that is usable for people who do
understand the local script/language, and who don't by setting all names
e.g.
name=('name:en|name:int|mkgmap:trans:name''(name in e.g. Japanese Script) '

A quick patch attached which is a first attempt at such a thing.

Usage:

   ${name|ascii:}
   ${name|latin1:}

You need the colon there at the moment, but I will fix that if we go
with this syntax. An alternative syntax could be: ${name|transliterate:ascii}

Even better would of course be if there would be an additional function
to check if "name" is already in two scripts - this is often the case
for Japan or Thailand or Singapore... Dunno if that is easy to
implement. I hope/guess the above /mkgmap:trans:name/ would be easy, as
the code exists if you use e.g. --latin1.

--
keep on biking and discovering new trails

Felix
openmtbmap.org &www.velomap.org



_______________________________________________
mkgmap-dev mailing list
[email protected]
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev


Index: src/uk/me/parabola/mkgmap/osmstyle/actions/ValueBuilder.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/mkgmap/osmstyle/actions/ValueBuilder.java	(revision 3320)
+++ src/uk/me/parabola/mkgmap/osmstyle/actions/ValueBuilder.java	(revision )
@@ -224,6 +224,12 @@
 		case "part":
 			item.addFilter(new PartFilter(arg));
 			break;
+		case "ascii":
+			item.addFilter(new TransliterateFilter("ascii"));
+			break;
+		case "latin1":
+			item.addFilter(new TransliterateFilter("latin1"));
+			break;
 		}
 	}
 
Index: src/uk/me/parabola/mkgmap/osmstyle/actions/TransliterateFilter.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/mkgmap/osmstyle/actions/TransliterateFilter.java	(revision )
+++ src/uk/me/parabola/mkgmap/osmstyle/actions/TransliterateFilter.java	(revision )
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2014.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3 or
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ */
+package uk.me.parabola.mkgmap.osmstyle.actions;
+
+import uk.me.parabola.imgfmt.app.labelenc.TableTransliterator;
+import uk.me.parabola.imgfmt.app.labelenc.Transliterator;
+import uk.me.parabola.mkgmap.reader.osm.Element;
+
+/**
+ * Transliterate the string to ascii or latin.
+ */
+public class TransliterateFilter extends ValueFilter {
+	private static final Transliterator ASCII = new TableTransliterator("ascii");
+	private static final Transliterator LATIN1 = new TableTransliterator("latin1");
+
+	private final Transliterator trans;
+
+	public TransliterateFilter(String charset) {
+		if ("latin1".equals(charset))
+			trans = LATIN1;
+		else
+			trans = ASCII;
+	}
+
+	protected String doFilter(String value, Element el) {
+		return trans.transliterate(value);
+	}
+}
_______________________________________________
mkgmap-dev mailing list
[email protected]
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev

Reply via email to