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
The app is translating just fine but survey pages are set to the default.
SurveyorController extends ApplicationController where the local is populated, so I don't see why setting the locale in SurveyorController would change anything, but it did. Setting the locale in SurveyorController has the survey pages translate, but the survey content is set to default. The database translation requests (I know there's a PR to remove these) are set to "fr" but are still rendering "en" content:
SurveyTranslation Load (1.7ms) SELECT "survey_translations".* FROM "survey_translations" WHERE "survey_translations"."survey_id" = ? AND "survey_translations"."locale" = ? ORDER BY "survey_translations"."id" ASC LIMIT 1 [["survey_id", 15], ["locale", "fr"]]
CACHE (0.1ms) SELECT "survey_translations".* FROM "survey_translations" WHERE "survey_translations"."survey_id" = ? AND "survey_translations"."locale" = ? ORDER BY "survey_translations"."id" ASC LIMIT 1 [["survey_id", 15], ["locale", "fr"]]
CACHE (0.1ms) SELECT "survey_translations".* FROM "survey_translations" WHERE "survey_translations"."survey_id" = ? AND "survey_translations"."locale" = ? ORDER BY "survey_translations"."id" ASC LIMIT 1 [["survey_id", 15], ["locale", "fr"]]
CACHE (0.1ms) SELECT "survey_translations".* FROM "survey_translations" WHERE "survey_translations"."survey_id" = ? AND "survey_translations"."locale" = ? ORDER BY "survey_translations"."id" ASC LIMIT 1 [["survey_id", 15], ["locale", "fr"]]
Rendered partials/_answer.html.haml (83.7ms)
CACHE (0.1ms) SELECT "survey_translations".* FROM "survey_translations" WHERE "survey_translations"."survey_id" = ? AND "survey_translations"."locale" = ? ORDER BY "survey_translations"."id" ASC LIMIT 1 [["survey_id", 15], ["locale", "fr"]]
CACHE (0.2ms) SELECT "survey_translations".* FROM "survey_translations" WHERE "survey_translations"."survey_id" = ? AND "survey_translations"."locale" = ? ORDER BY "survey_translations"."id" ASC LIMIT 1 [["survey_id", 15], ["locale", "fr"]]
Rendered partials/_answer.html.haml (46.4ms)
CACHE (0.1ms) SELECT "survey_translations".* FROM "survey_translations" WHERE "survey_translations"."survey_id" = ? AND "survey_translations"."locale" = ? ORDER BY "survey_translations"."id" ASC LIMIT 1 [["survey_id", 15], ["locale", "fr"]]
CACHE (0.1ms) SELECT "survey_translations".* FROM "survey_translations" WHERE "survey_translations"."survey_id" = ? AND "survey_translations"."locale" = ? ORDER BY "survey_translations"."id" ASC LIMIT 1 [["survey_id", 15], ["locale", "fr"]]
Rendered partials/_answer.html.haml (43.6ms)
CACHE (0.1ms) SELECT "survey_translations".* FROM "survey_translations" WHERE "survey_translations"."survey_id" = ? AND "survey_translations"."locale" = ? ORDER BY "survey_translations"."id" ASC LIMIT 1 [["survey_id", 15], ["locale", "fr"]]
CACHE (0.1ms) SELECT "survey_translations".* FROM "survey_translations" WHERE "survey_translations"."survey_id" = ? AND "survey_translations"."locale" = ? ORDER BY "survey_translations"."id" ASC LIMIT 1 [["survey_id", 15], ["locale", "fr"]]
Rendered partials/_answer.html.haml (43.3ms)
CACHE (0.1ms) SELECT "survey_translations".* FROM "survey_translations" WHERE "survey_translations"."survey_id" = ? AND "survey_translations"."locale" = ? ORDER BY "survey_translations"."id" ASC LIMIT 1 [["survey_id", 15], ["locale", "fr"]]
CACHE (0.1ms) SELECT "survey_translations".* FROM "survey_translations" WHERE "survey_translations"."survey_id" = ? AND "survey_translations"."locale" = ? ORDER BY "survey_translations"."id" ASC LIMIT 1 [["survey_id", 15], ["locale", "fr"]]
Rendered partials/_answer.html.haml (39.9ms)
Rendered partials/_question.html.haml (537.9ms)
Rendered partials/_section.html.haml (563.5ms)
I checked the value of I18n.locale in _answer.html.haml and it was also fr. Pretty odd.
Any ideas what I could be doing wrong?
The text was updated successfully, but these errors were encountered:
It does not look like the translations were ever implemented in full. "survey_translations" only references survey_id and not any of the translatable models like Question or Answer with their own text fields, so it would not be very useful.
@yoon Okay, I saw the yaml files, but initially I assumed they are just part of DSL, and not also used for retrieving the translations.
Edit:
It seems to be working on my end, the yaml content for the entire survey is stored in the SurveyTranslation model. One caveat however is that the questions and answers (or any other fields to be translated) must have reference identifiers, which cannot be just numbers, since they will just end up as numeric keys in hash returned from parsing the yaml content, and translates finds the translation by reference_identifier (which is a string key). This can be fixed by something like deep_stringify_keys, which is available in Rails 4.
The app is translating just fine but survey pages are set to the default.
SurveyorController extends ApplicationController where the local is populated, so I don't see why setting the locale in SurveyorController would change anything, but it did. Setting the locale in SurveyorController has the survey pages translate, but the survey content is set to default. The database translation requests (I know there's a PR to remove these) are set to "fr" but are still rendering "en" content:
I checked the value of
I18n.locale
in _answer.html.haml and it was also fr. Pretty odd.Any ideas what I could be doing wrong?
The text was updated successfully, but these errors were encountered: