Skip to content
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

Localization Arabic #401

Open
sam961 opened this issue Dec 25, 2020 · 4 comments
Open

Localization Arabic #401

sam961 opened this issue Dec 25, 2020 · 4 comments

Comments

@sam961
Copy link

sam961 commented Dec 25, 2020

I cannot make locaization from english to arabic
example
let text = "List of <nameStyle>%@</nameStyle>'s devices".localizedWithParameters(name)

In the localized string i have the following :
"List of <nameStyle>%@</nameStyle>'s devices"="الأجهزة <nameStyle>%@</nameStyle>'الخاصة";

Please help

@ZevEisenberg
Copy link
Collaborator

Where is localizedWithParameters coming from? I don't think that's part of BonMot. I wonder if the order of the %@ in the Arabic string is messing up the positional format? Maybe try swapping the order?

@sam961
Copy link
Author

sam961 commented Dec 26, 2020

i created a protocol it is the same as :
let text = String(format: NSLocalizedString("List of <nameStyle>%@</nameStyle>'s devices", comment: ""), "My Name")

but the text is not translated

"List of <nameStyle>%@</nameStyle>'s devices"="TEST <nameStyle>%@</nameStyle>TEST";

@ZevEisenberg
Copy link
Collaborator

@sam961 oh, I missed something in your original post. You had <tags> without backticks, so GitHub didn't render them because it thought they were HTML tags. I've edited your original post to make this more clear, and I'll keep investigating the issue.

@ZevEisenberg
Copy link
Collaborator

ZevEisenberg commented Dec 31, 2020

@sam961 I was not able to reproduce the issue. I set up my localized strings file like this:

"List of <nameStyle>%@</nameStyle>'s devices"="الأجهزة <nameStyle>%@</nameStyle>'الخاصة";

In my app code, here's how I set up the styling. I used an existing app, so the code has more than you should need to get it working, but here's the gist:

        label.attributedText = String(format: NSLocalizedString("List of <nameStyle>%@</nameStyle>'s devices", comment: "foo"), "Zev").styled(with: StringStyle([
            .adapt(.control),
            .font(UIFont.systemFont(ofSize: 30, weight: .medium)),
            .color(.tutorialText),
            .alignment(.center),
            .xmlRules([
                .style("nameStyle", StringStyle(.color(.red))),
            ]),
        ]))

Result:

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