Language pairs strings how to
(1) By jose isaias cabrera (jicman) on 2021-11-20 20:35:42 [source]
I am planning a website to have both English and Spanish strings. These strings would be in SQLite. The idea is for a person to click on the language and be able to choose between the two languages and the website would populate on the chosen language. The question is what is the best way to do this? For example:
CREATE TABLE IF NOT EXIST Headers (H1, H2, H3);
This will take care of the English. I am stuck on whether I create a Headers_es (H1, H2, H3) also to address the Spanish language. I know there are probably many ways to do this, but, I would like some opinion from the experts. Any guidance would be greatly appreciated. Thanks.
(2) By Simon Slavin (slavin) on 2021-11-20 20:51:19 in reply to 1 [link] [source]
I don't think there is one solution which I could recommend in all cases. It comes down to different levels of data.
A) You could make two different database files. One has the strings in English, one in Spanish.
B) You could make one database with two tables: one table with the English strings, one with the Spanish strings.
C) You could make one table but have two different rows for each purpose: one row has the English strings, the other row has the Spanish strings.
D) Or you could have both languages in the same row:
CREATE TABLE IF NOT EXIST Headers (HE1, HE2, HE3, HS1, HS2, HS3);
Part of it is about whether you might add another language to your solution. For instance, if you might eventually add another language, you would not want to use the HE1, HS2 solution because making the changes would be tedious.
(3) By RandomCoder on 2021-11-21 03:32:29 in reply to 1 [link] [source]
One option I've seen used is a table something like:
CREATE TABLE strings(id INT, lang TEXT, string TEXT); INSERT INTO strings VALUES (1, 'en', 'Hello World'); INSERT INTO strings VALUES (1, 'es', 'Hola Mundo'); INSERT INTO strings VALUES (2, 'en', 'Header'); INSERT INTO strings VALUES (2, 'es', 'El encabezamiento');
It has the advantage of being fairly easy to add new languages or words and phrases without needing to change schemas.