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

Apple: Localization Schema #3475

Open
wants to merge 15 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions pxr/usd/usdUI/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ pxr_library(usdUI
vt
sdf
usd
usdGeom

PUBLIC_HEADERS
api.h
Expand Down Expand Up @@ -42,3 +43,17 @@ pxr_register_test(testUsdUISceneGraphPrim
PYTHON
COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdUISceneGraphPrim"
)

pxr_build_test(testUsdUILocalizationAPI
LIBRARIES
tf
usd
usdUI
CPPFILES
testenv/testUsdUILocalizationAPI.cpp
)

pxr_register_test(testUsdUILocalizationAPI
COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdUILocalizationAPI"
EXPECTED_RETURN_CODE 0
)
2 changes: 2 additions & 0 deletions pxr/usd/usdUI/generatedSchema.classes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

# Public Classes
backdrop
localizationAPI
nodeGraphNodeAPI
sceneGraphPrimAPI
tokens

# Python Module Files
module.cpp
wrapBackdrop.cpp
wrapLocalizationAPI.cpp
wrapNodeGraphNodeAPI.cpp
wrapSceneGraphPrimAPI.cpp
wrapTokens.cpp
Expand Down
1 change: 1 addition & 0 deletions pxr/usd/usdUI/generatedSchema.module.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@
TF_WRAP(UsdUINodeGraphNodeAPI);
TF_WRAP(UsdUISceneGraphPrimAPI);
TF_WRAP(UsdUIBackdrop);
TF_WRAP(UsdUILocalizationAPI);
TF_WRAP(UsdUITokens);
61 changes: 61 additions & 0 deletions pxr/usd/usdUI/generatedSchema.usda
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,64 @@ class Backdrop "Backdrop" (
)
}

class "LocalizationAPI" (
doc = """This API describes em Language localization information for attributes.

It may be used to provide alternate language definitions for content like strings and asset paths that are
displayed to a user.
Runtimes may present the best language for a given users preference with this information.

OpenUSD leaves it up to the runtime that is consuming it to handle localized presentations.
As such, support for localization may vary across runtimes.

\\important Lookup of localized attributes may be expensive, so are recommended to be used sparingly
It is recommended, but not enforced, to only use them for strings and asset paths.
Support for localization of different attributes may vary depending on the application runtime that
the data is brought into.


\\note Language identifiers must use the BCP-47 list of languages. However, since USD cannot currently use
hyphens in identifiers, any hyphens are replaced with underscores. This is similar in strategy to other
systems that adhere closely to the Unicode Identifier specification. e.g en-ca is en_CA .
Take care when converting language identifiers to a systems own formatting.

A default language is specifiable on a prim. This is the language that is assumed when attributes do
not include their own identifier for language. The default language is explicitly inherited by
all prims under the current prims hierarchy.

\\note Provide default localization information on the default prim of the layer, and any top level prims.
It is not recommended to keep declarations of the default localization to a minimum throughout the rest of
the hierarchy within a single layer.

Attributes are suffixed with :lang:<identifier> when expressing languages other than the default.

For example, \"string text\" would implicitly be in the default localization language, but you may have
\"string text:lang:fr\" for French.

Runtimes may provide their own logic for choosing which langauge to display, but following BCP-47,
a recommended logic set is:

- If a preferred language is available within the set of declared languages, pick that language exactly.
e.g \"en_CA\" should not pick simply \"en\" if \"en_CA\" is available

- If a preferred language isn't available, check for a more specific version of that language.
e.g \"de_DE\" may match to \"de_DE_u_co_phonebk\"

- If a more specific language is not available, pick a less specific language.
e.g \"en_US\" may match to \"en\"

- If a less specific language choice is not available, pick the attribute without language specification.
"""
)
{
uniform token localization:__INSTANCE_NAME__:language (
doc = """The default language for this prim hierarchy. This may only be created with the default instance name.

\\note If no default localization language is provided, the runtime may optionally try and infer the
language of the text.
If the runtime does not infer the langauge, it should assume the language is in the users preferred language,
which may be derived from the system or current user context.
"""
)
}

Loading