Merge pull request #12580 from dannon/localize-directive-improvement

Update localization directive to trim whitepsace around text content.
This commit is contained in:
Marius van den Beek
2021-10-27 19:13:28 +02:00
committed by GitHub
3 changed files with 5 additions and 5 deletions
@@ -27,7 +27,7 @@
</template>
<b-dropdown-item @click.stop="$emit('delete')">
<span v-localize>Delete Collection Only </span>
<span v-localize>Delete Collection Only</span>
</b-dropdown-item>
<b-dropdown-item @click.stop="$emit('delete', { recursive: true })">
+1 -1
View File
@@ -51,7 +51,7 @@
<span class="fa fa-cubes" />
</template>
<b-dropdown-item v-for="v of availableVersions" :key="v" @click="$emit('onChangeVersion', v)">
<span class="fa fa-cube" /><span v-localize>Switch to </span>{{ v }}</b-dropdown-item
<span class="fa fa-cube" /><span v-localize>Switch to</span> {{ v }}</b-dropdown-item
>
</b-dropdown>
<b-button
@@ -8,11 +8,11 @@ const newlineMatch = /\r?\n|\r/g;
const doublespaces = /\s\s+/g;
const localizeDirective = {
// TODO consider using a different hook if we need dynamic updates in content translation
bind(el, binding, vnode) {
el.childNodes.forEach((node) => {
const oneline = node.textContent.replace(newlineMatch, " ");
const singleSpaces = oneline.replace(doublespaces, " ");
node.textContent = _l(singleSpaces);
const standardizedContent = node.textContent.replace(newlineMatch, " ").replace(doublespaces, " ").trim();
node.textContent = _l(standardizedContent);
});
},
};