Dynamic creation of variables, based upon a database table

The other day, as I fiddled with my weekend project, I stumbled into a concept that I had not thought of previously.  I was looking to make it as easy as possible to make the app multi-lingual.  In trying to separate the application from the translations, I came up with an interesting technique.

 

 

When you select a language, it loads records associated with your selected language.  They have the attributes of “name” and “value”.  It loops through the returned records and uses “name” as the variable name and “value” as the value.  When you add a new record to the table, it automagically adds the new variable.

Dynamic Variables - DB Schema

Dynamic Variables - DB Content

Dynamic Variables - App Output EN

Dynamic Variables - App Output SP

Dynamic Variables - App Output LA

As you can see, addition of new translations pretty easy.  Have a thought on the technique? Feel free to leave a comment or drop me a line.

Leave a Reply

Your email address will not be published. Required fields are marked *