-
-
Notifications
You must be signed in to change notification settings - Fork 50
SIL Locale Data Repository
The SLDR contains standard LDML information sourced from the CLDR and can be retrieved with the API's below.
Usage: https://ldml.api.sil.org/ws_id?[optional parameters list]
where ws_id
is the IETF language tag for the writing system and the optional parameters (delimited by &
) are as follows:
Parameter | Description |
---|---|
inc[] |
Repeatable parameter for what elements to include in the generated LDML. If no inc[] parameter is used, then all elements are included. <identity> will always be included so it doesn't need to be specified. |
uid |
This parameter causes the server to return a file with the following properties: identity/special/sil:identity/@uid is set to the specified uid value, or auto-generated if uid=unknown
|
revid |
If specified, the value for this parameters is the value of identity/special/sil:identity/@revid
|
ext |
Extension for returned LDML file; default ext=xml
|
Reference for the SLDR API.
https://ldml.api.sil.org/en-US?uid=123456&inc[]=characters&inc[]=collations&ext=ldml
Requests the LDML file for language English, script Latin, region US, uid
=123456, and containing elements <identity>
, <characters>
, and <collations>
. The file will have an ".ldml" extension
https://ldml.api.sil.org/en-Latn?uid=unknown&inc[]=layout
Automatically redirected to download the LDML file for language English, script Latin, region US, with a new uid
, and containing elements <identity>
and <layout>
.
The SIL.WritingSystems assembly provides an API for accessing the SLDR. LDML files can be downloaded from the SLDR using the Sldr.GetLdmlFile
method. The return value indicates whether the LDML was not found, downloaded from the SLDR, or retrieved from the local cache. The Sldr.LanguageTags
property returns information on all of the available language tags in the SLDR. The language tag information is parsed from the alltags.txt file that is provided by the SLDR. The alltags.txt file is retrieved from the SLDR GitHub repo.
To facilitate scenarios where the user is offline and unable to access the SLDR, a caching mechanism is implemented as described in this flowchart The SLDR also handles scenarios where the user already has the latest LDML file from the SLDR, or when the SLDR redirects the user to the likely language tag.
Many of the writing system classes contained in the SIL.WritingSystems assembly attempt to access the SLDR during normal use. This can be be an issue for unit tests that utilize the writing system classes. The SIL.TestUtilities assembly provide the OfflineSldrAttribute
and OfflineSldr
classes to help unit test authors to enable offline mode for the SLDR, so that unit tests are not attempting to access the SLDR. OfflineSldrAttribute
is a NUnit action attribute that can be placed on test fixtures, test assemblies, or tests. It is important to note that NUnit action attributes a executed after test setup and test fixture setup methods. OfflineSldr
is a disposable class that can be used in a using
block to enable offline mode for any arbitrary code.
The SLDR has a staging area for testing new changes. To add &staging=1
to the URL, set the environment variable SLDR_USE_STAGING=true