You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be really nice to have sqlpage handle internationalization for us. Maybe using a cookie for switching between languages and fallback to Accept-Language, and a json file in sqlpage directory for adding translations for each locale.
Right now the only option would be to use a (temporary?) table or write a function for handling this, which would require manually reading from the headers and cookies for every single text on the web page.
I'm thinking something like this:
SELECT'text'AS component, sqlpage.i18n('home_title') as title;
Hi !
Here is a link to a previous discussion on this topic: #248
I am not excluding implementing the solution described in this feature request in the future, but the current recommended solution is to handle internationalization directly in the database, by defining your own custom localized message fetching logic.
An example of what this could look like is:
SET lang =sqlpage.cookie('lang');
select'hero'as component, t($lang, 'home_title') as title;
with a translation function defined like this (postgresql example):
CREATE OR REPLACEFUNCTIONt(language VARCHAR(5), key VARCHAR(255))
RETURNS VARCHAR(255) AS $$
DECLARE
result VARCHAR(255);
BEGINSELECT translation_value INTO result
FROM language
WHERE language_code = language AND translation_key = key;
RETURN result;
END;
$$ LANGUAGE plpgsql;
It would be really nice to have sqlpage handle internationalization for us. Maybe using a cookie for switching between languages and fallback to Accept-Language, and a json file in sqlpage directory for adding translations for each locale.
Right now the only option would be to use a (temporary?) table or write a function for handling this, which would require manually reading from the headers and cookies for every single text on the web page.
I'm thinking something like this:
Wouldn't be too hard to implement and should be sufficient for pretty much all applications.
The text was updated successfully, but these errors were encountered: