Skip to content

How do I use different locale #20

@Hultner

Description

@Hultner

In the UCA standard's introduction they present an example as the following

Language Swedish: German:
-- z < ö ö < z

@jtauber How would I achieve this with PyUCA?

If I use the foreign C++ bindings with PyICU I can produce the above example like this

>>> def collate_compare(collator, a, b): return collator.getSortKey(a) > collator.getSortKey(b)
...
>>> col_de = Collator.createInstance(Locale("de_DE"))
>>> col_de.setStrength(Collator.PRIMARY)
>>> col_se = Collator.createInstance(Locale("sv_SE"))
>>> col_se.setStrength(Collator.PRIMARY)
>>> collate_compare(col_de, "ö", "z") # German: ö is more than z => False
False
>>> collate_compare(col_se, "ö", "z") # Swedish: ö is more than z => True
True

However, I would much prefer a pure python solution without mixing in external C++ dependencies as these make installation and usage cumbersome. I could not find any guidance in the documentation on how to achieve this goal with PyUCA so would love any help or pointers.

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