在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):microsoft/localizationkit开源软件地址(OpenSource Url):https://github.com/microsoft/localizationkit开源编程语言(OpenSource Language):Python 99.3%开源软件介绍(OpenSource Introduction):localizationkit
Included are tests for various things such as:
with lots more to come. Getting startedConfigurationTo use the library, first off, create a configuration file that is in the TOML format. Here's an example: default_language = "en"
[has_comments]
minimum_comment_length = 25
minimum_comment_words = 8
[token_matching]
allow_missing_defaults = true
[token_position_identifiers]
always = false This configuration file sets that You can now load in your configuration: from localizationkit import Configuration
configuration = Configuration.from_file("/path/to/config.toml") Localization CollectionsNow we need to prepare the strings that will go in. Here's how you can create an individual string: from localizationkit import LocalizedString
my_string = LocalizedString("My string's key", "My string's value", "My string's comment", "en") This creates a single string with a key, value and comment, with its language code set to from localizationkit import LocalizedCollection
collection = LocalizedCollection(list_of_my_strings) Running the testsAt this point, you are ready to run the tests: import localizationkit
results = localizationkit.run_tests(configuration, collection)
for result in results:
if not result.succeeded():
print("The following test failed:", result.name)
print("Failures encountered:")
for violation in result.violations:
print(violation) Not running the testsSome tests don't make sense for everyone. To skip a test you can add the following to your config file at the root: blacklist = ["test_identifier_1", "test_identifier_2"] Rule documentationMost tests have configurable rules. If a rule is not specified, it will use the default instead. Some tests are opt in only. These will be marked as such. Comment LinebreaksIdentifier: Checks that comments for strings do not contain linebreaks. Comments which contain linebreaks can interfere with parsing in other tools such as dotstrings. Comment SimilarityIdentifier: Checks the similarity between a comment and the string's value in the default language. This is achieved via Configuration
Duplicate KeysIdentifier: Checks that there are no duplicate keys in the collection. Configuration
Has CommentsIdentifier: Checks that strings have comments. Note: Only languages that have Latin style scripts are really supported for the words check due to splitting on spaces to check. Configuration
Has ValueIdentifier: Checks that strings have values. Since any value is enough for some strings, it simply makes sure that the string isn't None/null and isn't empty. Configuration
Invalid TokensIdentifier: Checks that all format tokens in a string are valid. Note: This check is not language specific. It only works very broadly. Key LengthIdentifier: Checks the length of the keys. Note: By default this test doesn't check anything. It needs to have parameters set to positive values to do anything. Configuration
Objective-C Alternative TokensIdentifier: Checks that strings do not contain Objective-C style alternative position tokens. Objective-C seems to be allows positional tokens of the form Placeholder token explanationIdentifier: Checks that if a placeholder is used in a string, the comment explicitly explains what it is replaced with. Precondition: Each placeholder in the string and its explanation in comment is expected to follow Swift InterpolationIdentifier: Checks that strings do not contain Swift style interpolation values since these cannot be localized. Token MatchingIdentifier: Checks that the tokens in a string match across all languages. e.g. If your English string is "Hello %s" but your French string is "Bonjour", this would flag that there is a missing token in the French string. Configuration
Token Position IdentifiersIdentifier: Check that each token has a position specifier with it. e.g. Configuration
ContributingThis project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com. When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA. This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论