Commit Graph

15 Commits

Author SHA1 Message Date
Javi Martín
0b613158da Update TranslationHelper monkey-patch
The `translate` method now receives keyword arguments instead of a hash
of options.
2022-08-24 14:36:49 +02:00
Javi Martín
e38c1d637b Cache content cache key on a per-request basis
We do a similar thing with the settings helper, caching settings on a
per-request basis.

Using an instance variable in a helper reduces the amount of times we
need to calculate the cache key during a single request.

Even if Rails caches SQL queries per request, the test suite is faster
with this change, and we get rid of many redundant queries in the logs.
2020-12-15 12:19:41 +01:00
Javi Martín
41dba842a6 Cache I18nContent translations
This way we avoid fetching each translation every time it's requested.
This reduces the amount of queries in the development logs and also
makes the test suite faster.
2020-12-15 11:57:09 +01:00
decabeza
af1e11838c Fix custom translations with options 2020-04-10 12:17:27 +02:00
Javi Martín
ea2aeab383 Apply rubocop Rails/FindBy rule everywhere
We didn't detect these cases because by default the rule only searches
for offenses in `app/models/`.
2019-11-08 19:15:04 +01:00
Javi Martín
49e55b4dc4 Apply Rails/DynamicFindBy rubocop rule
We were already using `find_by` most of the time.

Since there are false positives related to our `find_by_slug_or_id!` and
`find_by_manger_login` methods, which cannot be replaced with `find_by`,
I'm adding it indicating the "refactor" severity.
2019-10-23 20:05:40 +02:00
Javi Martín
9d627f2db9 Remove redundant I18nContent scope
Since two records cannot have the same key, having a scope that will
always return just one record is the same as using `find_by_key`.
2019-09-24 19:29:46 +02:00
Javi Martín
a5ba13b599 Apply Rails/Presence rubocop rule 2019-09-10 21:43:38 +02:00
Julian Herrero
a8d8d2cdf9 Use double quotes in config/initializers 2019-03-15 10:29:03 +01:00
rgarcia
4c8b174274 Display only translations for the current language
After creating a translation in spanish, it was also displaying it when selecting
the english locale.

This was due to the code picking the first translation available

With this commit, we are checking for an existing translation in the current locale
and displaying it if it exists
2018-07-26 21:55:07 -04:00
Angel Perez
113981c573 Avoid unnecessary DB call on I18nTranslation initializer 2018-07-26 19:09:36 -04:00
Angel Perez
7255c6cb9b Fallback to default I18n value if translation is not available 2018-07-26 19:07:47 -04:00
Angel Perez
bc152acaf2 Don't evaluate a conditional and assign a variable on the same line 2018-07-26 19:06:44 -04:00
Angel Perez
26965b43ee Clean I18n codebase 2018-07-26 19:06:29 -04:00
Raúl Fuentes
6d6dc32c38 Complete basic I18n backend and frontend 2018-07-26 19:06:19 -04:00