Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4265758
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T06:40:04+00:00 2026-05-21T06:40:04+00:00

when our app sends SMS messages, we’d like to give users the option to

  • 0

when our app sends SMS messages, we’d like to give users the option to specify their preferred language.

Using Spanish as an example, I see how to add a new locale yml file to config/locales.

And I see how to replace any hardcoded strings such as “text STOP to opt-out” with :stop_opt_out in my app.

what I don’t see is how to select the language used on a user-by-user basis.

specifically if my code is currently:

msg_out = "Thank you!"

and after internationalization I have :thank_you defined in multiple locale yml files

and if in my user record I have user.locale = “en” or “sp” (or should I enumerate locales 0,1,2?)

how would I do a user specific

msg_out = t :thank_you

that would apply to every message created for that user in the current session?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T06:40:05+00:00Added an answer on May 21, 2026 at 6:40 am

    If all your messages are generated when the user is using your site (i.e. all messages are sent as responses to user actions), you can just read the preferred locale out of the User model in a before_filter on your Application Controller (more on this here):

    class ApplicationController < ActionController::Base
        before_filter :load_user
        before_filter :load_locale
        #...
    
        def load_locale
            I18n.locale = (@user && @user.locale)? @user.locale : I18n.default_locale
        end
    
        #...
    end
    

    If you’re sending your messages asynchronously (e.g. nightly mass-mailings), you’ll have to load it per user:

    User.find_each do |user|
        I18n.locale = user.locale || I18n.default_locale
        # Send your message...
    end
    

    And if you’re sending generic mass-emails (i.e. with no per-user customizations), you can probably speed the above code up drastically by loading lists of users grouped by locale, and then sending a single message to all of them at once.

    Hope this helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're building an app that sends email using our clients' servers. The servers have
I'm using PandaStream, which sends a REST notification as YAML to our ASP.NET app.
In our app under development we are using Core Data with a sqlite backing
I've added the following code to our PHP Mail app which sends out emails:
I'd like to build a feature into our web app that involves receiving and
I'm trying to develop an app that sends email, and our internal network is
I'm using a Javascript to ask our app (which is in Google App Engine)
I am using Web2Py to create a simple app which sends Push notifications through
My app collects various types of information and sends it off to our server.
I don't have very much information to work with here, yet. Our app sends

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.