Fix "0" substitutions

master
Vitaliy Filippov 2021-08-30 02:12:53 +03:00
parent bf9262c351
commit 8eb8527f94
2 changed files with 8 additions and 2 deletions

View File

@ -1,6 +1,6 @@
{
"name": "babel-plugin-react-translate",
"version": "1.0.2",
"version": "1.0.3",
"description": "Babel-based JS/JSX auto-translator for Russian language",
"main": "index.js",
"scripts": {

View File

@ -46,7 +46,13 @@ export function L(s)
if (arguments.length > 1)
{
const arg = arguments;
s = s.replace(/\{(\d+)\}/g, (m, m1) => (arg[parseInt(m1)]||''));
s = s.replace(/\{(\d+)\}/g, (m, m1) =>
{
let r = arg[parseInt(m1)];
if (r == null)
r = '';
return r;
});
s = s.replace(
/\{N:(\d+):((?:[^:\\]+|\\.)*):((?:[^:\\]+|\\.)*):((?:[^:\\]+|\\.)*)\}/g,
(m, m1, m2, m3, m4) => plural(