New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Non-breaking space ( ) and other special chars #318
Comments
Hello. |
For most characters just paste the character in the text - all modern tools support Unicode fine. For things like non-breaking spaces the escape codes are useful because otherwise they're kind of hard to see as they look just like normal spaces most of the time. |
The thing is that in French, To demonstrate the issue, in French you'd expect to see this:
However, if this reaches the end of a line, the
That's why there is a (narrow) non-breaking space instead of a regular space, this way the word will come along.
However, using |
@Xowap If your translators are OK with typing |
@Xowap it's easy to enter the unicode character for non-breaking space:
Personally, I have a french BÉPO keyboard and writing non-breaking spaces is as easy as pressing shift + space. |
In my experience, translators forget to insert any form of (N)NBSP. I agree that the actual unicode characters are easier to safely move around. @laurentpayot I think we can agree that moving everybody to BEPO is not an easy fix for this @avenla-mvirkkunen sure I can (and do) code things myself but the problem is at least affecting every application translated to French and I guess that other languages are affected too. Some standard way of dealing with this oft-ignored problem would be pretty nice. |
I'm looking at a similar problem, but I am trying to insert « and » in french translations. Is there a way of doing this that I haven't figured out? I tried putting in javascript escape sequences, but those are rendered as text as well. |
HTML escapes just represent Unicode characters so all you need to do is use the characters as-is. Non-breaking spaces and such are a bit of a special case because most editors don't make it easy to tell apart from normal spaces, but « and » are just normal characters so there's no need to use an escape sequence at all. |
Thanks! I don't know why I didn't think of that, but it worked perfectly of course. |
Hi, It would be great to have non encoded/decoded messages, as it was in 8.1.0 version (if my tests are corrects). I understand the idea of decode/encode and use of v-html, it's probably great, but changing the default behavior of $t function has some drawbacks (doesn't ensure backward compatibility with previous versions). Are there any solution to "hack" the behavior of $t function and return to the 8.1.0 behavior ? thanks. |
Up to this point, we've been using non-breaking spaces that are visually identical to normal spaces. But we should have some kind of space that is visually distinct. Adding the unicode character sequence is a better solution. Note: there is a mention in the discussion that we should be using half-spaces but we haven't been doing that so far. Source: - kazupon/vue-i18n#318 - http://www.fileformat.info/info/unicode/char/00a0/index.htm
If we can avoid to ask translators to add such entities or special characters, I think we all agree that it is better. I've just found out that there is a postTranslation: (str) => str.replace(' ?', '\xa0?').replace(' !', '\xa0!') |
Here's a small utility to handle common french punctuation: // Replaces white spaces before or after some punctuations by non breaking spaces
// Eg. replaces " ?" by " ?" or "« " by "« " to avoid unwanted line breaks
const addNbspAroundPunctuation = (str) =>
str.replace(/\s+([:;»!?/])|([«])\s+/g, (match, left, right) => {
if (left) {
return `\xa0${left}`;
}
if (right) {
return `${right}\xa0`;
}
}); The characters list is not exhaustive. |
we supported in Vue I18n v9. |
@kazupon how I can use this feature? I didn't find it in the docs |
Here is a solution. You need to use the windows ascii input. *On the other hand, I don't know if the ALT code is different depending on the keyboard type/language. |
I had read the new documentation here https://vue-i18n.intlify.dev/guide/essentials/syntax.html#special-characters and for @ as example i just had to change it in the message to {'@'} and it works 👍 |
Both
v-t
and$t
doesn't support special chars like
and so on. Using$t
withv-html
works well, but frequently it is needed as a "plain text" (without rendering HTML). By the way another localization plugins (e.g.vue-multilanguage
) support this feature.The text was updated successfully, but these errors were encountered: