Store users’ locale in database
-
Hello,
I was wondering if users’ locale preferences are stored anywhere in the database.
For example, when I send out notification emails, how can I know the language preference of the users to which the notification is going?
Thank you.
-
Hello
The set of users locales WPGlobus keeps in ‘wpglobus_option_locale’ option.
As for notifications I think it depends on ‘Site Language’ option on page options-general.phpHey, thanks.
I need a little more clarification:
I see the wpglobus_option_locale in the “wp_options” table. But the value seems like a long list of all possible locales.
I want to know where a user’s locale preference is stored (if at all) in the database.And the second part of my question:
The reason I need the user’s locale is because I want to send emails in the user’s preferred language. So, would it be possible to set the language to the user’s preferred language while constructing his email notification?Thanks.
> I want to know where a user’s locale preference is stored (if at all) in the database.
WPGlobus doesn’t store user’s locale preference.
> And the second part of my question:
You need yourself to make improvements ( for example in user’s profile ) to store and using user’s preferred language.
Ok, thank you.
Regarding my second question: Now let’s say I have the language which the user prefers, how would I apply it when constructing my email.
Ordinarily I would wrap the text (eg:
__('Your post has received a reply', 'my-text-domain');), but this will just use the default language. How do I specify the user’s language for the text so that text in users’ emails is according to their preference?Thank you.
Again
“You need yourself to make improvements ( for example in user’s profile ) to store and using user’s preferred language.”
What does it mean?
For example we have 3 language: ‘en, ru, es’.
1. you need to give to user ability set preferred language in profile. Let it be ‘es’.
2. prepare e-mail texts in 3 languages and save them in DB
3. before send e-mail to user you must extract ‘es’ text from DB.
You can do it so$text = get_option('my_mail_text'); $text_for_send = WPGlobus_Core::text_filter($text, 'es'); wp_mail( $to, $subject, $text_for_send );How do I input “my_mail_text” into the DB?
Do I generate the multilingual text myself (eg: “{:en}hello{:}{:fr}bonjeur{:}”)? Or is there a WPGlobus function that does this?
Is there any way to use my mo and po files for this? So that I don’t have to enter each custom phrase into my DB?Thanks
>> How do I input “my_mail_text” into the DB?
>> Do I generate the multilingual text myself (eg: “{:en}hello{:}{:fr}bonjeur{:}”)? Or is there a WPGlobus function that does this?You can use Custom Post Type for creating and storing e-mail texts.
>> Is there any way to use my mo and po files for this? So that I don’t have to enter each custom phrase into my DB?
Maybe
From the documentation, the best way I can see to do what I want is:
1) Add all text that I would like in my email via:
add_option($option_name, WPGlobus_Utils::build_multilingual_string());2) Extract text when composing the email with
WPGlobus_Utils::text_filter(get_option(), $email_locale...)Again, if there is a way to achieve what I want with text that is stored in an
mofile (rather than storing it in the database), I would prefer that. Because that way all of my translated text will be in one place (as opposed to being both in the database and inmofiles). Is this possible? If so, how?Thank you.
> if there is a way to achieve what I want with text that is stored in an mo file. Is this possible? If so, how?
Please, read
https://core.trac.ww.wp.xz.cn/ticket/26511
The topic ‘Store users’ locale in database’ is closed to new replies.