Skip to content

R.swift not work well with automatic grammar agreement (^[..](inflect: true)) #858

@susi021

Description

@susi021

For example, when I define the string "%lld person" = "^[%lld person](inflect: true)"; in localizable.string, and call it with the R.string.localizable.lldPerson(2), it will return ^[2 person](inflect: true), not the 2 people as I expected.

To leverage the automatic grammar agreement, I need to define the following:

"person" = "person";
"%lld %@" = "^[%lld %@](inflect: true)";

Use the R.swift to get the translation:

let person = R.string.localizable.person()
let attributedString = AttributedString(localized: "\(num) \(person)")
return String(attributedString.characters)

So that it will return "2 people", which is translated and pluralized.

Is there any better way to do that?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions