We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Translation table scheme

Hi, there!

I'm implementing a multi-language system for my application and searching by Phalcon's support to achieve this, I found a custom Adapter via Incubator (https://github.com/phalcon/incubator/tree/master/Library/Phalcon/Translate/Adapter).

Following the documentation, Phalcon is expecting a table with this scheme:

CREATE TABLE translations ( key_name varchar(32) NOT NULL, value text, PRIMARY KEY (key_name) )

IMO, first of all, this structure isn't much consistent. Secondly, I want to use my own structure. So I ask: it's a good habit/practice to change the query's behavior directly in Incubator or it's better to create my own translation adapter? And if I want to create my own Adapter, where is the right place to put my file in?

And more: following the table's scheme indicated by Incubator, how does Phalcon knows which is the language that the user is looking for?

Cheers!

I searched about the subject and no answers. Then I created a consistent (and smart!) solution for my project and contributed to the project by requesting a pull right here: https://github.com/phalcon/incubator/pull/70

What's your opinion about my solution? Should I follow this way?

Left a comment on your pull request. Basically, should have a locale column instead of language, and make it bigger. I wonder if the guy who wrote the database adapter was thinking you would have a different table for each language.

Hey Mark!

I thought the same thing as you: maybe the guy that created the table's scheme was drunk to think about the Phalcon's users will create a table per language?

Anyway, let's chat in the PR! :) Thank you!