The main idea is that the developer can get a translations without any care if it exists or not in the DB.
The algorithm is:
1. The front controller (or the action controller) tells the Translation which "context" to load. If the context doesn't exist a new one is created in the DB. The context string is the name of the controller and the action currently executed.
Code: Select all
$Translation->load($controller_name, $action_name);Code: Select all
$Translation->load('user', 'edit');Code: Select all
$Translation->get('label_username');Code: Select all
$controller_name."_".$action_name." label_username"The main problem is that the translation can be entered only if the code requesting for it has been reached and run.
While it's very comfortable for the developer not to care about the translation, it's not guaranteed that after some usage all of the needed translations would be requested.
I know that I could use a "register" method, but If I do so, I'll use all the beauty of my idea
Also, some of the requests for translation are made dynamically. For example the reports of the system request their header column names by using the DB column name in the current context. So, if change the structure of the report in the DB layer, I don't need to do anything in the application layer. The only thing which has to be done is to translate the new column headers.
To summarize: I don't want to use statically defined translations in any way (i.e. by registering translation requests), but I still need to be sure that all of the possible translation requests will find their matches in the DB. I am almost sure, it's some how impossible to do this by using exactly this approach, but I need ideas.
I have an idea - the worst one
I may parse all of my *.php files and to extract all of the needed translations. Well, it won't work for the dynamically created ones