From 3f2430c3ae22cf2afd657d2b065beebff89f5e4e Mon Sep 17 00:00:00 2001 From: Tatu Aalto Date: Sat, 11 May 2024 11:33:22 +0300 Subject: [PATCH] Fix unit tests --- ...cumentation.test_many_plugins.approved.txt | 40 +++++++++++++++++++ ...on.test_parse_plugin_init_doc.approved.txt | 2 + 2 files changed, 42 insertions(+) diff --git a/utest/test/api/approved_files/PluginDocumentation.test_many_plugins.approved.txt b/utest/test/api/approved_files/PluginDocumentation.test_many_plugins.approved.txt index 391a5a73e..edad20566 100644 --- a/utest/test/api/approved_files/PluginDocumentation.test_many_plugins.approved.txt +++ b/utest/test/api/approved_files/PluginDocumentation.test_many_plugins.approved.txt @@ -378,6 +378,46 @@ documentation for further details. Plugin API is new SeleniumLibrary 4.0 += Language = + +SeleniumLibrary offers possibility to translte keyword names and documentation to new language. If language +is defined, SeleniumLibrary will search from +[https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#module-search-path | module search path] +Python packages starting with `robotframework_seleniumlibrary_translation` by using +[https://packaging.python.org/en/latest/guides/creating-and-discovering-plugins/ | Python pluging API]. Library +is using naming convention to find Python plugins. + +The package must implement single API call, ``get_language`` without any arguments. Method must return a +dictionary containing two keys: ``language`` and ``path``. The language key value defines which language +the package contains. Also value should match (case insentive) the library ``language`` import parameter. +The path parameter value should be full path to the translation file. + +== Translation file == + +The file name or extension is not important, but data must be in [https://www.json.org/json-en.html | json] +format. The keys of json are the methods names, not the keyword names, which implements keywords. Value of +key is json object which contains two keys: ``name`` and ``doc``. The ``name`` key contains the keyword +translated name and `doc` contains translated documentation. Providing doc and name are optional, example +translation json file can only provide translations to keyword names or only to documentatin. But it is +always recomended to provide translation to both name and doc. Special key ``__intro__`` is for class level +documentation and ``__init__`` is for init level documentation. These special values ``name`` can not be +translated, instead ``name`` should be kept the same. + +== Generating template translation file == + +Template translation file, with English language can be created by running: +`rfselib translation /path/to/translation.json` command. Command does not provide translations to other +languages, it only provides easy way to create full list keywords and their documentation in correct +format. It is also possible to add keywords from library plugins by providing `--plugings` arguments +to command. Example: `rfselib translation --plugings myplugin.SomePlugin /path/to/translation.json` The +genered json file contains `sha256` key, which constains the sha256 sum of the library documentation, +the sha256 sum is used by `rfselib translation --compare /path/to/translation.json` command, which compares +transation to to library and prints outs a table which tell if there are changes needed for translation file. + +Example project for translation can be found from +[https://github.com/MarketSquare/robotframework-seleniumlibrary-translation-fi | robotframework-seleniumlibrary-translation-fi] +repository. + = Plugin: my_lib = Some dummy documentation. diff --git a/utest/test/api/approved_files/PluginDocumentation.test_parse_plugin_init_doc.approved.txt b/utest/test/api/approved_files/PluginDocumentation.test_parse_plugin_init_doc.approved.txt index db0eb9db6..935242b1e 100644 --- a/utest/test/api/approved_files/PluginDocumentation.test_parse_plugin_init_doc.approved.txt +++ b/utest/test/api/approved_files/PluginDocumentation.test_parse_plugin_init_doc.approved.txt @@ -19,3 +19,5 @@ SeleniumLibrary can be imported with several optional arguments. Default value to wait for page load to complete until a timeout exception is raised. - ``action_chain_delay``: Default value for `ActionChains` delay to wait in between actions. +- ``language``: + Defines language which is used to translate keyword names and documentation.