Commit Graph

13 Commits

Author SHA1 Message Date
Javi Martín
fdfdbcbd0d Add and apply Style/ArgumentsForwarding rule
We were using generic names like `args` and `options` which don't really
add anything to `*` or `**` because Ruby required us to.

That's no longer the case in Ruby 3.2, so we can simplify the code a
bit.
2024-04-11 17:59:40 +02:00
Javi Martín
8898c30f55 Rename AvailableLocales.available_locales method
I'm not sure whether we should rename the class instead. I'm renaming
the method because renaming the class would require more changes.
2023-08-30 14:46:35 +02:00
Javi Martín
2b9f9ed557 Fix crash translating an already translated text
The page was crashing when at least part of the content of the page had
been translated between the request showing the remote translations
button and the moment people pressed the button.
2023-02-16 17:52:17 +01:00
Javi Martín
2f0327acf8 Use remote translations objects instead of hashes
This way we can simplify the code dealing with the translatable
association.
2023-02-16 17:52:17 +01:00
Javi Martín
26cc75a891 Move remote translations controller methods to the model
Now that all the code related to this model is in the same place,
changing it will be easier.
2023-02-16 17:52:17 +01:00
Javi Martín
d09a47a023 Move remote translations concern methods to the model
This way it'll be easier to change the code.
2023-02-16 17:52:17 +01:00
Javi Martín
e7fcca9b47 Check remote translations locales at runtime
We were evaluating its value when the server starts. On production
enviroments, that could mean weeks or months before the available
locales are checked again, and so it would be possible to use a list
which is no longer in sync with the list provided by microsoft.
2020-04-28 15:45:32 +02:00
taitus
d853366d38 Add RemoteTranslation validations
- Validate that locale is a valid locale for RemoteTranslation Client.
- RemoteTranslation can only be created for resources that do not have the requested
language translated
2020-02-26 16:47:13 +01:00
Javi Martín
db97f9d08c Add and apply rubocop rules for empty lines
We were very inconsistent regarding these rules.

Personally I prefer no empty lines around blocks, clases, etc... as
recommended by the Ruby style guide [1], and they're the default values
in rubocop, so those are the settings I'm applying.

The exception is the `private` access modifier, since we were leaving
empty lines around it most of the time. That's the default rubocop rule
as well. Personally I don't have a strong preference about this one.


[1] https://rubystyle.guide/#empty-lines-around-bodies
2019-10-24 17:11:47 +02:00
taitus
1d3dd6f727 Add RemoteTranslationsCaller to new namespace
- Rename to Caller
 - Add to new namespace RemoteTranslations
 - Update references to new namespace
2019-06-27 09:21:18 +02:00
taitus
4272b60339 Create Remote Translations Caller
This module is used in a callback model and in charge of
  - extracting resources associated from RemoteTranslation and preparing
    its fields to be sent to the MicrosoftTranslateClient thought DelayedJobs
  - receive the response from MicrosoftTranslateClient and update resource
    with his translates

Co-authored-by: javierm <elretirao@gmail.com>
2019-06-27 09:21:18 +02:00
taitus
744a3d48fd Create RemoteTranslations Controller
- Create RemoteTranslations Controller to receive resources without
  translations and create RemoteTranslation instances when theirs
  translations are not enqueued.
- Create remote_translation_enqueued? class method on RemoteTranslation
  model to check if exists same remote translations without errors
  pending to translate.
2019-06-27 09:21:18 +02:00
taitus
04810f5080 Create RemoteTranslation model
- Each RemoteTranslation is associated with a resource (through polymorphic)
  and has the locale to we want translate.
- After create a RemoteTranslation we create a enqueue_remote_translation
  method that will be send remote translation instance to remote translation
  client
2019-06-27 09:20:25 +02:00