Module z_trans_server

Simple server to manage the translations, owns the ets table containing all translations.

Copyright © 2010-2017 Marc Worrell

Behaviours: gen_server.

Authors: Marc Worrell (marc@worrell.nl).

Description

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.

Function Index

code_change/3Convert process state when code is changed.
handle_call/3Trap unknown calls.
handle_cast/2Rebuild the translations table.
handle_info/2Handling all non call/cast messages.
init/1Initiates the server.
load_translations/1Parse all .po files and reload the found translations in the trans server.
load_translations/2Take a proplist with dicts and reload the translations table.
observe_module_ready/2Reload the translations when modules are changed.
set_context_table/1Set the table id in the context to the newest table id.
start_link/1Starts the server.
start_tests/0
table/1Return the name of the ets table holding all translations.
terminate/2This function is called by a gen_server when it is about to terminate.

Function Details

code_change/3

code_change(OldVsn, State, Extra) -> any()

Convert process state when code is changed

handle_call/3

handle_call(Message, From, State) -> any()

Trap unknown calls

handle_cast/2

handle_cast(Message, State) -> any()

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

handle_info/2

handle_info(Info, State) -> any()

Handling all non call/cast messages

init/1

init(X1::{Site::atom(), Name::atom()}) -> {ok, #state{}}

Initiates the server.

load_translations/1

load_translations(Context::z:context()) -> ok

Parse all .po files and reload the found translations in the trans server

load_translations/2

load_translations(Trans::map(), Context::z:context()) -> ok

Take a proplist with dicts and reload the translations table. After reloading the the template server is flushed.

observe_module_ready/2

observe_module_ready(X1::module_ready, Context::z:context()) -> ok

Reload the translations when modules are changed.

set_context_table/1

set_context_table(Context::z:context()) -> z:context()

Set the table id in the context to the newest table id

start_link/1

start_link(Site::atom()) -> {ok, pid()} | {error, term()}

Starts the server

start_tests/0

start_tests() -> {ok, pid()} | {error, term()}

table/1

table(Site::atom() | z:context()) -> atom()

Return the name of the ets table holding all translations

terminate/2

terminate(Reason, State) -> any()

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.


Generated by EDoc