z_trans_server (zotonic_core v1.0.0-rc.12)

Simple server to manage the translations, owns the ets table containing all translations. When new translations are read then the previous table is kept and the one before the previous is deleted.

Link to this section Summary

Functions

Convert process state when code is changed
Rebuild the translations table. Call the template flush routines afterwards. Trans is a map with all translations per translatable string.
Handling all non call/cast messages
Initiates the server.
Parse all .po files and reload the found translations in the trans server
Take a proplist with dicts and reload the translations table. After reloading the the template server is flushed.
Reload the translations when modules are changed.
Set the table id in the context to the newest table id
Starts the server
Return the name of the ets table holding all translations
This function is called by a gen_server when it is about to terminate. It should be the opposite of Module:init/1 and do any necessary cleaning up. When it returns, the gen_server terminates with Reason. The return value is ignored.

Link to this section Functions

Link to this function

code_change(OldVsn, State, Extra)

Convert process state when code is changed
Link to this function

handle_call(Message, From, State)

Trap unknown calls
Link to this function

handle_cast(Message, State)

Rebuild the translations table. Call the template flush routines afterwards. Trans is a map with all translations per translatable string.
Link to this function

handle_info(Info, State)

Handling all non call/cast messages
-spec init({Site :: atom(), Name :: atom()}) -> {ok, #state{}}.
Initiates the server.
Link to this function

load_translations(Context)

-spec load_translations(z:context()) -> ok.
Parse all .po files and reload the found translations in the trans server
Link to this function

load_translations(Trans, Context)

-spec load_translations(map(), z:context()) -> ok.
Take a proplist with dicts and reload the translations table. After reloading the the template server is flushed.
Link to this function

observe_module_ready(_, Context)

-spec observe_module_ready(module_ready, z:context()) -> ok.
Reload the translations when modules are changed.
Link to this function

set_context_table(Context)

-spec set_context_table(z:context()) -> z:context().
Set the table id in the context to the newest table id
Link to this function

start_link(Site)

-spec start_link(Site :: atom()) -> {ok, pid()} | {error, term()}.
Starts the server
-spec start_tests() -> {ok, pid()} | {error, term()}.
-spec table(atom() | z:context()) -> atom().
Return the name of the ets table holding all translations
Link to this function

terminate(Reason, State)

This function is called by a gen_server when it is about to terminate. It should be the opposite of Module:init/1 and do any necessary cleaning up. When it returns, the gen_server terminates with Reason. The return value is ignored.