From d1ffa295d6bbd9a48ae66c93329b3546404712c3 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Thu, 7 Jan 2021 08:11:22 +0100 Subject: [PATCH] cockpit-po-plugin: Fix crash with plural forms Declare the `pos` variable. Fixes regression introduced in commit 7f6ef51c12a7. Add plural forms to German translations to exercise this code path. --- po/de.po | 1 + src/lib/cockpit-po-plugin.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/po/de.po b/po/de.po index cc551d7..91b4e60 100644 --- a/po/de.po +++ b/po/de.po @@ -12,6 +12,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=n != 1\n" #: src/index.html:20 msgid "Cockpit Starter Kit" diff --git a/src/lib/cockpit-po-plugin.js b/src/lib/cockpit-po-plugin.js index 4cf0f28..221a6ca 100644 --- a/src/lib/cockpit-po-plugin.js +++ b/src/lib/cockpit-po-plugin.js @@ -59,7 +59,7 @@ module.exports = class { // We know the brace in is the location to insert our function if (plurals) { - pos = output.indexOf('{', 1); + const pos = output.indexOf('{', 1); output = output.substr(0, pos + 1) + "'plural-forms':" + String(plurals) + "," + output.substr(pos + 1); }