Questions tagged [rails-i18n]
Repository for collecting Locale data for Ruby on Rails I18n as well as other interesting, Rails related I18n stuff.
776
questions
0
votes
0
answers
25
views
asserting value of selector
The following Minitest snippet
puts response.body.inspect
# assert response.body.include?("Log out of all other sessions")
assert_select "input[type='submit']" do
assert_select ...
0
votes
1
answer
24
views
Rails I18n ActiveRecord model attributes after migration
I started creating an app, and planned out my basic scaffolding. Let's say I created this resource:
rails g scaffold CircusAnimal fieldOne:string fieldTwo:string
I'm using Rails I18n to translate the ...
0
votes
0
answers
50
views
Safety and translation of query params in Ruby on Rails
I have a two part question. I'm passing params to links in order to sort and filter in my Ruby on Rails app. Is this type of resulting url safe?
/realestates?column=salesprice&direction=desc
If ...
1
vote
0
answers
20
views
Issue with Rails 5.2.4 translation method
The index view pushed by the Scheduler::ProductionJobsController index method contains the following request to the translation method:
<h2> <%= t('.View') %> </h2>
The config\...
0
votes
1
answer
19
views
Rails I18n default_locale and fallbacks by user preference
Rails internationalization has a nice fallback feature where empty linguistic versions don't show empty content, but a default locale's content via application configuration in application.rb
...
0
votes
1
answer
69
views
Changing the language by I18n on ruby on rails - leads to the fact that the language sometimes changes by itself
I made a language change and it works, but sometimes after several page updates, the language changes to another, then back - please help, I don't know what to do here
Method for lang change:
def ...
0
votes
1
answer
24
views
Simple Form Checkboxes - applying styling
I have two models in many-to-many relationship.
class Rental < ApplicationRecord
has_and_belongs_to_many :features
end
and
class Feature < ApplicationRecord
has_and_belongs_to_many :rentals
...
0
votes
1
answer
27
views
How to get Rails "new" path after failed form-input
I am implementing a simple language switcher in the common HTML menu-bar on a website in Rails, where the locale is path-based with the Rails-standard I18n implementation, e.g., /en/articles for Index ...
0
votes
1
answer
30
views
Rails Validation - Remove or Modify Nested Model Names
I have a few name-spaced Models, with relationships to each other as such:
my_ns/main.rb
module MyNs
class Main < ApplicationRecord
has_many :secondary
accepts_nested_attributes_for :...
0
votes
0
answers
63
views
How to localized URL's in Ruby On Rails
For now my routes.rb looks like this:
scope '(:locale)', locale: /en/ do
get I18n.t('routes.pages.about'), to: 'pages#about', as: 'about'
get 'media', to: 'pages#media', as: 'media'
...
0
votes
1
answer
37
views
Is there a way to only run i18n-tasks normalize on certain files?
We have i18n-tasks normalize running as part of a husky git commit hook but since we have added other locales it is now extremely slow to run.
Is it possible to pass file paths to i18n-tasks normalize ...
4
votes
1
answer
128
views
How to set raise_on_missing_translations for I18n
In rails 6.1.6.1 I have the following deprecation warning
DEPRECATION WARNING: action_view.raise_on_missing_translations is deprecated and will be removed in Rails 7.0. Set i18n....
0
votes
0
answers
13
views
Finding natural English text strings in codebase
I'm in the process of implementing I18n in a Rails project, which involves going through a vast number of files, looking for hard-coded English text, and replacing it with calls to the Translation ...
0
votes
1
answer
60
views
How use rails inflections with diferent languages
I using Rails 6.1.4, and I need to configure inflections in 2 languages, but when I try to use pluralize, the word not apply pluralize.
I need apply different rules in different languages, but don't ...
0
votes
1
answer
349
views
Rails JS localization issues, i18n-js gem
I'm trying to implement JS localization in Rails 7 app using i18n-js gem. I have some little script for validating contact form attachments and want to translate errors from that JS script.
I already ...
0
votes
0
answers
35
views
Routing Error when putting in routing scope for locale
I am trying to implement internationalization using Rails I18n api. After going through the docs, it suggests doing routing scope in routes.rb file to persist between links in the page which I did ...
2
votes
0
answers
139
views
Fetch Rails i18n translations to be rendered in React
I have a React/Rails application which I am setting up i18n translations. Using rails-i18n and i18n.js gems. I have en.yml and es.yml files for english and spanish. The translations seem to work well ...
1
vote
1
answer
270
views
Rails i18n ActiveModel: Translate error message for absence validation
I have this validation in a service class:
class Users::Updater
include ActiveModel::Validations
validates(:frozen_identification_data, absence: { message: 'Identification fields cannot be ...
0
votes
0
answers
59
views
How to add i18n to a Rails dropdown
I have a drop down menu to select three status written in enum. I also set up multiple dictionary files (yml) including English. However, I can't find a place to insert the i18n in the View, because ...
0
votes
0
answers
113
views
Rails 6 Change locale method is not changing the locale
I am using i18n for translation and for some odd reason is not working, is only changing the path, but not the actual locale.
Here is my view methods:
<% if cookies[:locale] == 'en' %>
&...
0
votes
1
answer
75
views
I encountered an error while sending mail, using ActionMailer within anI18n environment
My User class has an attribute language, which holds his preferred locale. At the same time, pages have also a :locale controlled by a menu dropdown list.
I support a password_reset action via a mail ...
0
votes
0
answers
146
views
Disable loading of nested locale (I18n) folders in Rails 7
After upgrading from Rails 6 to Rails 7, there seems to be a not-yet-fully-documented change in how I18n loads the config files. In Rails 7, files in subfolders (config/locales/<folder>/* are ...
1
vote
1
answer
277
views
How to localize Stimulus JS value using i18n?
I am working on rails 6 application where I'm trying to store all displayed strings in locales files. I have a Stimulus controller named countdown_controller.js:
import { Controller } from "@...
0
votes
1
answer
31
views
Encoding error due to JS Internationalization
After rails upgrade 6.0.4.1 to 6.1.4.1 the following error occurs:
ActionView::Template::Error ("\xC3" from ASCII-8BIT to UTF-8):
13:
14: <script type="text/...
3
votes
1
answer
243
views
Rails 7 unable to find localized template when using underscore locale (lang_region)
We are trying to update a Rails 6.1.4 app to the freshly released Rails 7.0.0 version. After following some guides and tweaking our basic configuration the app works just fine.
Our views using ...
0
votes
0
answers
462
views
Extract all available keys from an I18n::Backend
We're migrating our Rails app to using a different I18n backend, so not using the default yml files, or any files at all choosing to download the translations from an internal service.
In our previous ...
0
votes
1
answer
166
views
Rails Rendering issues with jQuery of i18n translation text with apostrophe inside an yml file
I have a Rails App ( ruby '2.7.4' and rails '6.0.3.3'), I'm using jQuery
It seams that I'm having issues with apostrophe ' inside i18n translation file inside a
When I add a translation to a file ...
0
votes
1
answer
413
views
Translate partials with i18n from shared folder in a Rails app
I am new using i18n in Rails, I am struggling to figure out how to translate a partial from the shared folder in another view.
I am using lazy loading in my application.rb file
config.i18n....
0
votes
1
answer
317
views
Uninitialized constant error while upgrading Rails (Ruby on Rails)
I am trying to upgrade Rails from 5.2 to 6.1. That requires i18n to be greater than equal to 1.6 (rails -> activesupport -> i18n), so upgraded the same from 0.7, but keep getting this error.
...
1
vote
0
answers
169
views
How to set locale with Grape API / Rails
I have a Rails 6 app and a related API with grape.
I want to set locale the same way.
In my routes :
scope '(:locale)', locale: /#{I18n.available_locales.join("|")}/ do
mount MyApi::...
0
votes
1
answer
366
views
I got "undefined method `to_model' for true:TrueClass" after upgrade from Turbolinks to Turbo with Devise
I have this controller
# app/controllers/users/sessions_controller
class Users::SessionsController < Devise::SessionsController
before_action :redirect_admin_user, only: [:new]
...
0
votes
1
answer
482
views
Rails default_url_options conflicts with params in path/url-helpers
In my Rails-6.1.4 application, I have introduced the locale filter in the routing-filter Gem to allow a language-locale in URL-paths like /en/articles (for locale "en"). Then, I find path ...
2
votes
1
answer
280
views
extract form labels for i18n in rails
Reading up on ActionView::Helpers::FormHelper, I see that it states:
The text of label will default to the attribute name unless a translation is found in the current I18n locale (through helpers....
0
votes
1
answer
40
views
Yaml use a key as block and value
I don't know if what I'm looking for is possible but I have the following YAML
en:
log:
model1:
update:
description: "My description for update"
variable1: "...
0
votes
1
answer
222
views
Rails Administrate : how to change interface language
I'm using Thoughtbot's Administrate library for the first time, everything is bright and shiny, but I can't find anything on the docs about translation.
From what I found in the changelog, the library ...
0
votes
1
answer
354
views
Cannot change locale in Rails
For some reason, it's not possible to change the locale in my app. I have created config/locales/el.yml and set the configuration in application.rb as follows:
config.i18n.default_locale = :en
...
-1
votes
2
answers
213
views
Rails I18n switch key based on user permissions
I have a namespace in my routes:
namespace :fruit do
resources :apple, only [:create, :destroy]
resources :banana, only [:show]
end
and also the same key in my translation file:
en:
fruit:
...
3
votes
1
answer
1k
views
Passing a dynamic set of interpolation arguments to rails-i18n?
I am upgrading to Rails 6.1.3 and with it, the latest version of rails-i18n (1.8.9).
I used to be able to pass a hash of interpolation arguments like this:
I18n.with_locale(:en) do
message = I18n....
0
votes
0
answers
294
views
Rails 18n French: Special Characters appear when words with accent are being used
I added french translation using i18n gem. Most of the french words with accent characters get printed correctly but some of the words are behaving incorrectly.
Sécurité gets printed instead of ...
1
vote
1
answer
344
views
I18n.t falls back to key instead to default locale
In my frontend non-translated strings are replaced with word form of their key instead of the translation of base language.
That means that changing locale to :en or :tr both shows Summaries Header ...
1
vote
2
answers
366
views
Text in helper won't translate
So here's the problem:
Let's say, I have mails. The text inside is fully translated and everything is just fine. May it look like this (we're using SLIM on this project):
= t('foo.bar')
= t('foo.bar')
...
2
votes
1
answer
837
views
How can I put CSS style in my I18n locale?
I have a following translation:
welcome: Hello there, %{general_kenobi}
Now I know, that I can put HTML tags in the translation, like <em> or so. But what if I want this general_kenobi to have ...
1
vote
1
answer
168
views
How to render class/controller specific translations on a partial in Rails 5.2?
My application manages several objects, but I try to DRY by using partials, and somehow common structure for them: all objects have id, code, name, description, updated_by and updated_at columns, at ...
2
votes
2
answers
56
views
Month in Spanish is capitalized when running test in Buildkite, but not in my development environment
I have a test that started failing in Buildkite...
Failure/Error: it { is_expected.to eq('Del 17 al 23 de febrero de 2019 (7 días)') }
expected: "Del 17 al 23 de febrero de 2019 (7 días)...
1
vote
1
answer
155
views
Which is the proper or best way to use i18n with many html tags on rails?
I have a code like that needs to be added to i18n, and I was wondering which would be the best/safest way to do it, For now I put it as is on i18n and called it on ruby code with a variable and ...
0
votes
1
answer
232
views
How to use I18n.locale with Hash#dig
I have the following Hash:
h = {
forms: {
version1: {
href: {
en: 'https://form1_en.example.org',
de: 'https://form1_de.example.org'
}
...
0
votes
1
answer
113
views
Seed rails db with I18n data
On rails 5.2, I want to populate my db with :en and :pt languages, I try :
Product.create!(
process: t('washed'),
category: coffee)
and then I give the translations in my en.yml and pt.yml files....
-1
votes
1
answer
205
views
Translation of active record models
I set the default_locale of my rails app to french: config.i18n.default_locale = :fr
Then I installed devise gem. And applied devise to the model Membre.
new.html.erb:
<h2><%= t('login') %>...
1
vote
1
answer
154
views
<% if I18n.locale == 'es' %> doesn't work
In my head.html.erb I have this
Language: <%= I18n.locale %>
<% if I18n.locale == 'es' %>This is Spanish
<% else % >This is NOT Spanish
<% end %>
But I see
Language: es
This ...
1
vote
2
answers
379
views
Why should we load translation using http in react-i18
I was going through React-i18 instructions and they have shared this snippet
import i18n from 'i18next';
import { initReactI18next } from 'react-i18next';
import Backend from 'i18next-http-backend';
...