@@ -148,3 +148,87 @@ Then Library can be imported in Robot Framework side like this:
148148``` robotframework
149149Library ${CURDIR}/PluginLib.py plugins=${CURDIR}/MyPlugin.py
150150```
151+
152+ # Translation
153+
154+ PLC supports translation of keywords names and documentation, but arguments names, tags and types
155+ can not be currently translated. Translation is provided as a file containing
156+ [ Json] ( https://www.json.org/json-en.html ) and as a
157+ [ Path] ( https://docs.python.org/3/library/pathlib.html ) object. Translation is provided in
158+ ` translation ` argument in the ` HybridCore ` or ` DynamicCore ` ` __init__ ` . Providing translation
159+ file is optional, also it is not mandatory to provide translation to all keyword.
160+
161+ The keys of json are the methods names, not the keyword names, which implements keyword. Value
162+ of key is json object which contains two keys: ` name ` and ` doc ` . ` name ` key contains the keyword
163+ translated name and ` doc ` contains keyword translated documentation. Providing
164+ ` doc ` and ` name ` is optional, example translation json file can only provide translations only
165+ to keyword names or only to documentatin. But it is always recomended to provide translation to
166+ both ` name ` and ` doc ` .
167+
168+ Library class documentation and instance documetation has special keys, ` __init__ ` key will
169+ replace instance documentation and ` __intro__ ` will replace libary class documentation.
170+
171+ ## Example
172+
173+ If there is library like this:
174+ ``` python
175+ from pathlib import Path
176+
177+ from robotlibcore import DynamicCore, keyword
178+
179+ class SmallLibrary (DynamicCore ):
180+ """ Library documentation."""
181+
182+ def __init__ (self , translation : Path):
183+ """ __init__ documentation."""
184+ DynamicCore.__init__ (self , [], translation.absolute())
185+
186+ @keyword (tags = [" tag1" , " tag2" ])
187+ def normal_keyword (self , arg : int , other : str ) -> str :
188+ """ I have doc
189+
190+ Multiple lines.
191+ Other line.
192+ """
193+ data = f " { arg} { other} "
194+ print (data)
195+ return data
196+
197+ def not_keyword (self , data : str ) -> str :
198+ print (data)
199+ return data
200+
201+ @keyword (name = " This Is New Name" , tags = [" tag1" , " tag2" ])
202+ def name_changed (self , some : int , other : int ) -> int :
203+ """ This one too"""
204+ print (f " { some} { type (some)} , { other} { type (other)} " )
205+ return some + other
206+ ```
207+
208+ And when there is translation file like:
209+ ``` json
210+ {
211+ "normal_keyword" : {
212+ "name" : " other_name" ,
213+ "doc" : " This is new doc"
214+ },
215+ "name_changed" : {
216+ "name" : " name_changed_again" ,
217+ "doc" : " This is also replaced.\n\n new line."
218+ },
219+ "__init__" : {
220+ "name" : " __init__" ,
221+ "doc" : " Replaces init docs with this one."
222+ },
223+ "__intro__" : {
224+ "name" : " __intro__" ,
225+ "doc" : " New __intro__ documentation is here."
226+ },
227+ }
228+ ```
229+ Then ` normal_keyword ` is translated to ` other_name ` . Also this keyword documentions is
230+ translted to ` This is new doc ` . The keyword is ` name_changed ` is translted to
231+ ` name_changed_again ` keyword and keyword documentation is translted to
232+ ` This is also replaced.\n\nnew line. ` . The library class documentation is translated
233+ to ` Replaces init docs with this one. ` and class documentation is translted to
234+ ` New __intro__ documentation is here. `
0 commit comments