Support = in locale files
clochix opened this issue · 2 comments
clochix commented
I wanted to use innerHTML
duck = run <a href="http://duck.net">baby</a>
But you use =
to split the string, so everything after href is lost.
Here's a quick fix proposal:
git diff --no-prefix
diff --git l10n.js l10n.js
index 3be588a..2924727 100644
--- l10n.js
+++ l10n.js
@@ -127,7 +127,7 @@ document.webL10n = (function(window, document, undefined) {
var reComment = /^\s*#|^\s*$/;
var reSection = /^\s*\[(.*)\]\s*$/;
var reImport = /^\s*@import\s+url\((.*)\)\s*$/i;
- var reSplit = /\s*=\s*/; // TODO: support backslashes to escape EOLs
+ var reSplit = /^([^=\s]*)\s*=\s*(.+)$/; // TODO: support backslashes to escape EOLs
// parse the *.properties file into an associative array
function parseRawLines(rawText, extendedSyntax) {
@@ -162,9 +162,9 @@ document.webL10n = (function(window, document, undefined) {
}
// key-value pair
- var tmp = line.split(reSplit);
- if (tmp.length > 1)
- dictionary[tmp[0]] = evalString(tmp[1]);
+ var tmp = line.match(reSplit);
+ if (tmp.length === 3)
+ dictionary[tmp[1]] = evalString(tmp[2]);
}
}
fabi1cazenave commented
agreed, thanks! WIP.
fabi1cazenave commented
solved with the latest commit, thanks again