Packages

Erlang gettext application

Current section

Files

Jump to
t__ doc dist search_items-f878083cb3.js
Raw

doc/dist/search_items-f878083cb3.js

searchNodes=[{"doc":"","ref":"t__.html","title":"t__","type":"module"},{"doc":"Returns the name of the application to which the calling process belongs. If the specified process does not belong to any application the function returns 't__'.","ref":"t__.html#application/0","title":"t__.application/0","type":"function"},{"doc":"Deletes configuration for the calling process application with infinity timeout. See also: t__:config_delete/2 .","ref":"t__.html#config_delete/0","title":"t__.config_delete/0","type":"function"},{"doc":"Deletes configuration for the specified application with infinity timeout. See also: t__:config_delete/2 .","ref":"t__.html#config_delete/1","title":"t__.config_delete/1","type":"function"},{"doc":"Deletes configuration for the specified application with the specified timeout. There is a blocking gen_server call behind this! That's why there is a config_delete_cast version of this function for convenience. Deleting applications config is possible but should not be abused. The system was designed for you to be able to change it at the application start or from an administration panel, from time to time.","ref":"t__.html#config_delete/2","title":"t__.config_delete/2","type":"function"},{"doc":"Deletes configuration for the specified application asynchronous Sends an asynchronous request to the process handling the implementation and returns ok immediately. See also: t__:config_delete/2 .","ref":"t__.html#config_delete_cast/1","title":"t__.config_delete_cast/1","type":"function"},{"doc":"Returns the current configuration for the calling process. Please notice that the language config record field may not be the same to the calling process application config because language can also be configured at the process level. (The process level language overwrites the application configured language). If you want to get the config holding application language, call t__:config/1 function. The function will perform the following steps: - call erlang:get(t__language) to get any calling process specific language that will overwrite the language returned from the next calls - call application:get_env(t__config) - call application:get_env(t__, t__config) - if no t__config environment key was set for both the current application or the t__ application we return t__ default config","ref":"t__.html#config_get/0","title":"t__.config_get/0","type":"function"},{"doc":"Returns the current configuration for the specified application. The function will perform the following steps: - call application:get_env(t__config) - call application:get_env(t__, t__config) - if no t__config environment key was set for both the current application or the t__ application we return t__ default config","ref":"t__.html#config_get/1","title":"t__.config_get/1","type":"function"},{"doc":"Returns the value of configuration t__config for Application","ref":"t__.html#config_get_environment/1","title":"t__.config_get_environment/1","type":"function"},{"doc":"Sets a new configuration for the calling process application with infinity timeout. See also: t__:config_set/3 .","ref":"t__.html#config_set/1","title":"t__.config_set/1","type":"function"},{"doc":"Sets a new configuration for the specified application with infinity timeout. See also: t__:config_set/3 .","ref":"t__.html#config_set/2","title":"t__.config_set/2","type":"function"},{"doc":"Sets a new configuration for the specified application with the specified timeout. There is a blocking gen_server call behind this! That's why there is a config_set_cast version of this function for convenience. However I don't recommend using that because you will not know if the operation failed. Changing applications config is possible but should not be abused. The system was designed for you to be able to change it at the application start or from an administration panel, from time to time.","ref":"t__.html#config_set/3","title":"t__.config_set/3","type":"function"},{"doc":"Sets a new configuration for the specified application asynchronous Sends an asynchronous request to the process handling the implementation and returns ok immediately. See also: t__:config_set/3 .","ref":"t__.html#config_set_cast/2","title":"t__.config_set_cast/2","type":"function"},{"doc":"Returns the current language for the calling process. When you properly setup the language for the process, the expected time complexity for the current implementation of this macro is O(1) and the worst case time complexity is O(N), where N is the number of items in the process dictionary. The function will perform the following steps in order to determine the default language: - call erlang:get(t__language) - call application:get_env(t__config) - call application:get_env(t__, t__config) - if no t__config environment key was set for both the current application or the t__ application we return t__ default language.","ref":"t__.html#language/0","title":"t__.language/0","type":"function"},{"doc":"Translate a singular or plural term, with or without repository, language and context This is the main translate function that does everything. using #t__p","ref":"t__.html#translate/1","title":"t__.translate/1","type":"function"},{"doc":"Translate with data See also: t__:translate/3 .","ref":"t__.html#translate/2","title":"t__.translate/2","type":"function"},{"doc":"Translate with data and reference as separate parameters using #t__p","ref":"t__.html#translate/3","title":"t__.translate/3","type":"function"},{"doc":"Translate with all separate parameters.","ref":"t__.html#translate/7","title":"t__.translate/7","type":"function"},{"doc":"","ref":"t__.html#t:config/0","title":"t__.config/0","type":"type"},{"doc":"","ref":"t__.html#t:p/0","title":"t__.p/0","type":"type"},{"doc":"","ref":"t__.html#t:repository/0","title":"t__.repository/0","type":"type"},{"doc":"","ref":"t___app.html","title":"t___app","type":"module"},{"doc":"This function is called whenever an application is started using start/1,2, and is to start the processes of the application. If the application is structured according to the OTP design principles as a supervision tree, this means starting the top supervisor of the tree.","ref":"t___app.html#start/2","title":"t___app.start/2","type":"function"},{"doc":"This function is called whenever an application has stopped. It is intended to be the opposite of Module:start/2 and is to do any necessary cleaning up. The return value is ignored.","ref":"t___app.html#stop/1","title":"t___app.stop/1","type":"function"},{"doc":"","ref":"t__languages.html","title":"t__languages","type":"module"},{"doc":"Select and return a proplist containing language specifications. If the language is not in our database, returns undefined.","ref":"t__languages.html#get_specs/1","title":"t__languages.get_specs/1","type":"function"},{"doc":"Return true if the specified language is a valid gettext language string or false otherwise. We don't actually validate all possible languages and locales/teritories/area codes, but we check the general format. As a result the implementation remain compatible with all possible iso_639 past and future codes. Many libraries out there miss some rare languages codes (including the academic or dead languages) because they try to validate based on a incomplete database. Please also notice that we are only interested in ISO 639 codes because if we don't recognize the ISO 639/area code combination we fall back on ISO 639 (either revision 1 or 2) code for determining the formula.","ref":"t__languages.html#is_gettext_language/1","title":"t__languages.is_gettext_language/1","type":"function"},{"doc":"","ref":"t__plural.html","title":"t__plural","type":"module"},{"doc":"Select and return the proper translation based on N and plural-forms If the proper translation can not be determined, the method returns first element of Msg parameter.","ref":"t__plural.html#select/3","title":"t__plural.select/3","type":"function"},{"doc":"","ref":"t__po.html","title":"t__po","type":"module"},{"doc":"Read and parse a PO file","ref":"t__po.html#file_read/1","title":"t__po.file_read/1","type":"function"},{"doc":"Write PO file","ref":"t__po.html#file_write/5","title":"t__po.file_write/5","type":"function"},{"doc":"","ref":"t__repository.html","title":"t__repository","type":"module"},{"doc":"Return the ETS table holding information for the specified application repository","ref":"t__repository.html#ets_table/2","title":"t__repository.ets_table/2","type":"function"},{"doc":"Update the specified repository (only if file changes are detected).","ref":"t__repository.html#update/2","title":"t__repository.update/2","type":"function"},{"doc":"Update the application repository","ref":"t__repository.html#update_force/2","title":"t__repository.update_force/2","type":"function"},{"doc":"","ref":"t__srv.html","title":"t__srv","type":"module"},{"doc":"Handle gen_server code change This function is called by a gen_server process when it is to update its internal state during a release upgrade/downgrade, that is, when the instruction {update,Module,Change,...}, where Change={advanced,Extra}, is specifed in the appup file. For more information, see section Release Handling Instructions in OTP Design Principles. For an upgrade, OldVsn is Vsn, and for a downgrade, OldVsn is {down,Vsn}. Vsn is defined by the vsn attribute(s) of the old version of the callback module Module. If no such attribute is defined, the version is the checksum of the Beam file. State is the internal state of the gen_server process. Extra is passed "as is" from the {advanced,Extra} part of the update instruction. If successful, the function must return the updated internal state. If the function returns {error,Reason}, the ongoing upgrade fails and rolls back to the old release.","ref":"t__srv.html#code_change/3","title":"t__srv.code_change/3","type":"function"},{"doc":"Config delete See t__:config_delete/2 for more details","ref":"t__srv.html#config_delete_call/2","title":"t__srv.config_delete_call/2","type":"function"},{"doc":"Config delete See t__:config_delete_cast/2 for more details","ref":"t__srv.html#config_delete_cast/1","title":"t__srv.config_delete_cast/1","type":"function"},{"doc":"Config set See t__:config_set/3 for more details","ref":"t__srv.html#config_set_call/3","title":"t__srv.config_set_call/3","type":"function"},{"doc":"Config set See t__:config_set_cast/3 for more details","ref":"t__srv.html#config_set_cast/2","title":"t__srv.config_set_cast/2","type":"function"},{"doc":"Handle gen_server calls Whenever a gen_server process receives a request sent using call/2,3 or multi_call/2,3,4, this function is called to handle the request. Request is the Request argument provided to call or multi_call. From is a tuple {Pid,Tag}, where Pid is the pid of the client and Tag is a unique tag. State is the internal state of the gen_server process. If {reply,Reply,NewState} is returned, {reply,Reply,NewState,Timeout} or {reply,Reply,NewState,hibernate}, Reply is given back to From as the return value of call/2,3 or included in the return value of multi_call/2,3,4. The gen_server process then continues executing with the possibly updated internal state NewState. For a description of Timeout and hibernate, see Module:init/1. If {noreply,NewState} is returned, {noreply,NewState,Timeout}, or {noreply,NewState,hibernate}, the gen_server process continues executing with NewState. Any reply to From must be specified explicitly using reply/2. If {stop,Reason,Reply,NewState} is returned, Reply is given back to From. If {stop,Reason,NewState} is returned, any reply to From must be specified explicitly using reply/2. The gen_server process then calls Module:terminate(Reason,NewState) and terminates.","ref":"t__srv.html#handle_call/3","title":"t__srv.handle_call/3","type":"function"},{"doc":"Handle gen_server casts Whenever a gen_server process receives a request sent using cast/2 or abcast/2,3, this function is called to handle the request. For a description of the arguments and possible return values, see Module:handle_call/3.","ref":"t__srv.html#handle_cast/2","title":"t__srv.handle_cast/2","type":"function"},{"doc":"Handle gen_server info This function is called by a gen_server process when a time-out occurs or when it receives any other message than a synchronous or asynchronous request (or a system message). Info is either the atom timeout, if a time-out has occurred, or the received message. For a description of the other arguments and possible return values, see Module:handle_call/3.","ref":"t__srv.html#handle_info/2","title":"t__srv.handle_info/2","type":"function"},{"doc":"Init gen_server Whenever a gen_server process is started using start/3,4 or start_link/3,4, this function is called by the new process to initialize. Args is the Args argument provided to the start function. If the initialization is successful, the function is to return {ok,State}, {ok,State,Timeout}, or {ok,State,hibernate}, where State is the internal state of the gen_server process. If an integer time-out value is provided, a time-out occurs unless a request or a message is received within Timeout milliseconds. A time-out is represented by the atom timeout, which is to be handled by the Module:handle_info/2 callback function. The atom infinity can be used to wait indefinitely, this is the default value. If hibernate is specified instead of a time-out value, the process goes into hibernation when waiting for the next message to arrive (by calling proc_lib:hibernate/3). If the initialization fails, the function is to return {stop, Reason}, where Reason is any term, or ignore.","ref":"t__srv.html#init/1","title":"t__srv.init/1","type":"function"},{"doc":"Creates a gen_server process as part of a supervision tree. The function should be called, directly or indirectly, by the supervisor. It will, among other things, ensure that the gen_server is linked to the supervisor.","ref":"t__srv.html#start_link/1","title":"t__srv.start_link/1","type":"function"},{"doc":"Handle gen_server terminate This function is called by a gen_server process when it is about to terminate. It is to be the opposite of Module:init/1 and do any necessary cleaning up. When it returns, the gen_server process terminates with Reason. The return value is ignored. Reason is a term denoting the stop reason and State is the internal state of the gen_server process. Reason depends on why the gen_server process is terminating. If it is because another callback function has returned a stop tuple {stop,..}, Reason has the value specified in that tuple. If it is because of a failure, Reason is the error reason. If the gen_server process is part of a supervision tree and is ordered by its supervisor to terminate, this function is called with Reason=shutdown if the following conditions apply: - The gen_server process has been set to trap exit signals. - The shutdown strategy as defined in the child specification of the supervisor is an integer time-out value, not brutal_kill. Even if the gen_server process is not part of a supervision tree, this function is called if it receives an 'EXIT' message from its parent. Reason is the same as in the 'EXIT' message. Otherwise, the gen_server process terminates immediately. Notice that for any other reason than normal, shutdown, or {shutdown,Term}, the gen_server process is assumed to terminate because of an error and an error report is issued using error_logger:format/2.","ref":"t__srv.html#terminate/2","title":"t__srv.terminate/2","type":"function"},{"doc":"","ref":"t__sup.html","title":"t__sup","type":"module"},{"doc":"Returns supervisor flags and child specifications.","ref":"t__sup.html#init/1","title":"t__sup.init/1","type":"function"},{"doc":"Creates a supervisor process as part of a supervision tree.","ref":"t__sup.html#start_link/1","title":"t__sup.start_link/1","type":"function"},{"doc":"Handle the upgrade process.","ref":"t__sup.html#upgrade/0","title":"t__sup.upgrade/0","type":"function"},{"doc":"","ref":"t__utils.html","title":"t__utils","type":"module"},{"doc":"Deletes file or directory File. If File is a directory, its contents is first recursively deleted. Same as new file:del_dir_r/1 introduced in OTP 23.0 for compatibility with older Erlang","ref":"t__utils.html#dir_del_r/1","title":"t__utils.dir_del_r/1","type":"function"},{"doc":"List files into the directory with the specified extension","ref":"t__utils.html#dir_list_files/3","title":"t__utils.dir_list_files/3","type":"function"},{"doc":"Convert a name (list, atom, binary) to string.","ref":"t__utils.html#name_to_string/1","title":"t__utils.name_to_string/1","type":"function"},{"doc":"Erlang gettext t__ is an implementation of the Gettext system in Erlang. gettext is an internationalization and localization system commonly used for writing multilingual programs on Unix-like computer operating systems. t__ is also available on HEX","ref":"readme.html","title":"Overview","type":"extras"},{"doc":"?T__("I have a joke about Erlang, but it requires a prologue.") Fast. Simple. Reading this file should be enough for understanding most use case scenarios. Documented source code with comments and specs. Highly configurable with multiple PO sources and languages per Erlang application or process. Supports contexts. Supports interpolation using familiar Erlang format control sequences (from io:format). Supports translating singular term with or without interpolation and with or without context. Supports translating plural term with or without interpolation and with or without context. Supports all plural terms formulas defined by UNICODE CLDR. Supports ETS tables based caching.","ref":"readme.html#features","title":"Overview - Features","type":"extras"},{"doc":"Erlang Gettext tools for multi-lingual capabilities: https://github.com/etnt/gettext Quick comparison with Erlang Gettext # Feature t__ gettext 1 Single macro that handles everything YES: T__ NO: TXT & TXT2 2 gettext contexts YES NO 3 gettext plural terms YES NO 4 Separate configurations for each application started at the same node YES NO 5 Diffrent language sources YES: using application 'repositories' YES: using diffrent languages servers 6 Developer mode/monitoring PO file changes YES: automatically detecting PO changes NO: requires manual reloading of the PO files 7 Cache YES: ETS reads/writes on the calling process (faster) YES: ETS reads/writes inside the translation gen_server","ref":"readme.html#alternatives","title":"Overview - Alternatives","type":"extras"},{"doc":"Gettext plural-forms formulas are hardcoded using a database. Work is underway to bypass this limitation and provide a full interpretor of any arbitrary gettext C formula.","ref":"readme.html#limitations","title":"Overview - Limitations","type":"extras"},{"doc":"Github pages: https://ergenius.github.io/t__/ '/doc' subdirectory (generated by ex_doc)","ref":"readme.html#documentation","title":"Overview - Documentation","type":"extras"},{"doc":"Full demo application provided You can find a full demo application on Github t__ demoapp . The application demonstrate most functionalities, including using multiple repositories and t__ being able to monitor repositories PO changes and reload them in real time. You can test this feature by modifying any PO files used by the demoapp while you run the application in console mode. A gen_server constinously translating strings on a timer is provided, so you can easily check the updates. Set/get the calling process language Set the language It is higly recommended to set the calling process language in order to avoid specifying the language for each ?T macro call. The specified language will be used by all ?T macros and functions for the current process if no explicit language is specified as a macro or function parameter. ? T__LANGUAGE ( "en" ) . ? T__LANGUAGE ( "en_GB" ) . ? T__LANGUAGE ( "ro" ) . Get the language Get the calling process language. When you properly setup the language for the process, the expected time complexity for the current implementation of this macro is O(1) and the worst case time complexity is O(N), where N is the number of items in the process dictionary. The function will perform the following steps in order to determine the default language: call erlang:get(t__language) call application:get_env(t__language) call application:get env(t_ , t__language) if no t language environment key was set for both the current application or the t application we return t default language defined in t .hrl file (wich is "en"). Language = ? T__LANGUAGE ( ) . T__ macro examples Singular terms ? T__ ( "I have a joke about Erlang, but it requires a prologue." ) . You can use binaries and atoms, however it is not recommended. ? T__ ( << "Erlang is user-friendly, it’s just picky about its friends!" >> ) . ? T__ ( 'Why can\\'t you trust atoms? Because they make up everything!' ) . Singular with context Context is useful for the translators to distinguish in between identical strings. ? T__ ( { "menu" , "Save" } ) . ? T__ ( { "menu" , "Quit" } ) . ? T__ ( { "button" , "Save" } ) . ? T__ ( { "button" , "Cancel" } ) . Context can also be used to create proper translations based on grammatical gender. ? T__ ( { "female" , "The cat belong to him/her" } ) . ? T__ ( { "male" , "The cat belong to him/her" } ) . Singular with repository Repositories are used to have different translations sources directories for the same application. For example let's assume your application has many HTML templates, each with his own translation directory. ? T__ ( { "template1" , { "Simple term from repository template1" } } ) . ? T__ ( { "template2" , { "Simple term from repository template2" } } ) . Repository can be combined with context also. ? T__ ( { "template1" , { "menu" , "Save" } } ) . Singular terms with interpolation ? T__ ( "~4.2f" , [ 3.56 ] ) . Context for gramatical gender with interpolation Context can also be used to create the proper translation based on grammatical gender combined with interpolation: ? T__ ( { "female" , "Her/his name is ~s " } , [ "Marry" ] ) . ? T__ ( { "male" , "Her/his name is ~s " } , [ "John" ] ) . Plural terms with interpolation: ? T__ ( [ " ~B user" , " ~B users" ] , [ 3 ] ) . Plural terms with context and interpolation ? T__ ( { "female" , [ " ~B file belongs to her/him" , " ~B files belong to her/him" ] } , [ 3 ] ) . ? T__ ( { "male" , [ " ~B file belongs to her/him" , " ~B files belong to her/him" ] } , [ 3 ] ) . Plural terms with context, interpolation and repositories ? T__ ( { "template1" , { "female" , [ " ~B file belongs to her/him" , " ~B files belong to her/him" ] } } , [ 3 ] ) . ? T__ ( { "template1" , { "male" , [ " ~B file belongs to her/him" , " ~B files belong to her/him" ] } } , [ 3 ] ) . Translate using #t__p{} record You can also specify everything using the #t p{} record as a single parameter to the T macro. This is actually the performance wise way of doing it. You will save some extra functions calls necessary to understand your tuples. All #t__p{} fields except msg are optional. ? T__ ( # t__p { msg = "Hello world" } ) . ? T__ ( # t__p { msg = "Her name is ~s " , data = [ "Marry" ] } ) . ? T__ ( # t__p { language = "ro" , context = "female" , msg = "Her/his name is ~s " , data = [ "Marry" ] } ) . ? T__ ( # t__p { repository = "module1" , language = "ro" , context = "male" , msg = "Her/his name is ~s " , data = [ "John" ] } ) . ? T__ ( # t__p { application = myapp , repository = "module1" , language = "ro" , context = "female" , msg = "Her/his name is ~s " , data = [ "Marry" ] } ) . Macro with all possible parameters separated For your convenience a macro also exists with all possible parameters: ? T__ ( Application , Repository , Language , Context , Msg , Data ) .","ref":"readme.html#usage","title":"Overview - Usage","type":"extras"},{"doc":"Is plural formula data correct? Short answer: Yes, if you trust CLDR Project. How plural formulas where generated from CLDR? For mantaining plural formulas database we started another project here: gettext-po-samples We use the following sources and tools for compiling the database: cldr.unicode.org PHP gettext language list TranslateHouse Formulas are automated generated by PHP gettext language list from CLDR. Each new release is manually checked and compared with the sources mentioned above. Data is compiled into plural-forms.eterm file. The same plural-forms.eterm file is used to generate src/t__plural.erl file.","ref":"readme.html#plural-formulas","title":"Overview - Plural formulas","type":"extras"},{"doc":"Continuously fixing bugs and tuning performance. Writing more testing units. Add more features.","ref":"readme.html#project-roadmap","title":"Overview - Project roadmap","type":"extras"},{"doc":"t__ officially supports OTP release 20 and later. Development takes place using OTP 25 release and tests are done on: 25.0.3 24.3.4 23.3.4 22.3.4 21.3.8 20.3.8 Unofficially, you may be able to use t__ with older Erlang versions. No guarantee included.","ref":"readme.html#erlang-versions-supported","title":"Overview - Erlang versions supported","type":"extras"},{"doc":"None.","ref":"readme.html#dependencies","title":"Overview - Dependencies","type":"extras"},{"doc":"Madalin Grigore-Enescu (ergenius) - Github ergenius.com","ref":"readme.html#authors","title":"Overview - Authors","type":"extras"},{"doc":"t__ is available under the MIT license (see LICENSE ).","ref":"readme.html#license","title":"Overview - License","type":"extras"},{"doc":"","ref":"changelog.html","title":"Changelog","type":"extras"},{"doc":"Initial release","ref":"changelog.html#0-1-0","title":"Changelog - 0.1.0","type":"extras"},{"doc":"September 1, 2022 Preparing for HEX release Added ExDoc config August 22, 2022 The library passed tests","ref":"changelog.html#pre-release","title":"Changelog - Pre release","type":"extras"},{"doc":"MIT License Copyright (c) 2022, Madalin Grigore-Enescu <https://github.com/ergenius> <https://ergenius.com> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.","ref":"license.html","title":"License","type":"extras"}]