summaryrefslogtreecommitdiff
path: root/webpack
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2018-05-17 09:28:31 +0900
committersyuilo <syuilotan@yahoo.co.jp>2018-05-17 09:28:31 +0900
commit14f7ff13ec13e282480e1be779dc25f080cf5f4c (patch)
tree3aefb607509d386ad8d838c154783a14dd37e13b /webpack
parentMerge pull request #1589 from rinsuki/fix/1428 (diff)
downloadsharkey-14f7ff13ec13e282480e1be779dc25f080cf5f4c.tar.gz
sharkey-14f7ff13ec13e282480e1be779dc25f080cf5f4c.tar.bz2
sharkey-14f7ff13ec13e282480e1be779dc25f080cf5f4c.zip
#491
Diffstat (limited to 'webpack')
-rw-r--r--webpack/i18n.ts24
1 files changed, 24 insertions, 0 deletions
diff --git a/webpack/i18n.ts b/webpack/i18n.ts
new file mode 100644
index 0000000000..de4d02e9d9
--- /dev/null
+++ b/webpack/i18n.ts
@@ -0,0 +1,24 @@
+/**
+ * Replace i18n texts
+ */
+
+export const pattern = /%i18n:([a-z0-9_\-@\.\!]+?)%/g;
+
+export const replacement = (ctx, match, key) => {
+ const client = '/src/client/app/';
+ let name = null;
+
+ const shouldEscape = key[0] == '!';
+ if (shouldEscape) {
+ key = key.substr(1);
+ }
+
+ if (key[0] == '@') {
+ name = ctx.src.substr(ctx.src.indexOf(client) + client.length);
+ key = key.substr(1);
+ }
+
+ const path = name ? `${name}|${key}` : key;
+
+ return shouldEscape ? `%i18n:!${path}%` : `%i18n:${path}%`;
+};