Skip to content

Why would I want my Python app to show: 'Hello, \u2068Jane\u2069!' #159

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

Closed
HeRo002 opened this issue Jan 26, 2021 · 2 comments
Closed

Why would I want my Python app to show: 'Hello, \u2068Jane\u2069!' #159

HeRo002 opened this issue Jan 26, 2021 · 2 comments

Comments

@HeRo002
Copy link

HeRo002 commented Jan 26, 2021

Hi!

I don't quite understand the documentation here:
https://www.projectfluent.org/python-fluent/fluent.runtime/stable/internals.html

This example:

greet = bundle.get_message('greet-by-name')
translated, errs = bundle.format_pattern(greet.value, {'name': 'Jane'})
translated
'Hello, \u2068Jane\u2069!'

Is explained like this:
You will notice the extra characters \u2068 and \u2069 in the output. These are Unicode bidi isolation characters that help to ensure that the interpolated strings are handled correctly in the situation where the text direction of the substitution might not match the text direction of the localized text.

But why would I want my user to look at this: 'Hello, \u2068Jane\u2069!'

@zbraniecki
Copy link
Collaborator

But why would I want my user to look at this: 'Hello, \u2068Jane\u2069!'

User should not see those characters. Instead, the layout engine of the UI should use those characters (invisible ones) to aid bidirectional text rendering. This is important because in case of localization it is both possible that Hello will be Right-To-Left, while Jane is Left-To-Right, and the reverse - the message may be Left-To-Right, but the name can be Right-To-Left.
Unicode Directionality Isolation Marks serve exactly that purpose.

Does it answer your question?

@HeRo002
Copy link
Author

HeRo002 commented Jan 27, 2021

Yes! Thank you!

@HeRo002 HeRo002 closed this as completed Jan 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants