Commit Graph

14280 Commits

Author SHA1 Message Date
taitus
aad6491049 Add remote translations to welcome 2019-06-27 09:21:19 +02:00
taitus
b3ae9038c3 Add remote translations to budget investments 2019-06-27 09:21:19 +02:00
taitus
c1f3a4ad3b Add remote translations to debates and proposals
Include RemotelyTranslatable concern on commentable actions to detect
remote translations on index and show controllers actions.
2019-06-27 09:21:19 +02:00
taitus
b6642f826e Shared example remotely translatable
We have 2 contexts that we want check:
  - Status from button to request translation
  - Status after click remote translations button
2019-06-27 09:21:19 +02:00
taitus
395143ba5a Display button or informative text
When all remote translations are enqueued we not display button but
we display informative text.

Co-Authored-By: alessandro <agileontheweb@gmail.com>
2019-06-27 09:21:19 +02:00
taitus
72d1893703 Manage the remote translation button display
- Add remote_translation_button partial to layout
- Only display button when we have remote_translations and if current
  locale is include on available locales from remote translations service.
- Recover available locales from remote translations service.
  Use daily_cache to detect every day if remote translation service has
  added new available locale.

Co-Authored-By: alessandro <agileontheweb@gmail.com>
2019-06-27 09:21:18 +02:00
taitus
cbd7ab7179 Add remote translation button
- Create partial to render remote translation button. This button will
  send remote_translations as json to remote translations controller.
- Add locales
- Add styles

Co-Authored-By: alessandro <agileontheweb@gmail.com>
2019-06-27 09:21:18 +02:00
taitus
6ad294e71f Fix houncibot offenses. 2019-06-27 09:21:18 +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
510307b0bd Add SentencesParser to new namespace
Add to new name space RemoteTranslations::Microsoft
2019-06-27 09:21:18 +02:00
taitus
4c1704a5a3 Add RemoteAvailableLocales to new namespace
Add to new name space RemoteTranslations::Microsoft and rename to
AvailableLocales.
2019-06-27 09:21:18 +02:00
taitus
d29656d78f Add MicrososftTranslateClient to new namespace
- Rename to Client
- Add to new namespace RemoteTranslations::Microsoft
- Update references to new namespace
2019-06-27 09:21:18 +02:00
taitus
91ba5ff879 Fix flakys specs 2019-06-27 09:21:18 +02:00
taitus
d2506358ef Fix found Hound violations 2019-06-27 09:21:18 +02:00
taitus
abb81fccf4 Allow create translations without length validation
We have changed validate_translation method on Globalize concern.
The objective is skip length validations when locale is distinct to
default_locale.

First we force apply :length validations when locale is equal to
default_locale. After we reject :length from options and apply rest
of validation options only when we have more than 1 options.

Ej: options = { length: "maximum: 10" }
When reject :length option in this example, options is equal to a
empty hash and we cant execute validations.
2019-06-27 09:21:18 +02:00
taitus
21f347778b Add Remote Translations Settings
- Add to seeds and dev_seeds
- Add locales
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
taitus
25e9c358ad Create RemotelyTranslatable concern controller
- Create concern to reuse the logic of detection of non-existent
  translations in Controllers.
- Add detect_remote_translation method:
  * This method will be called from controllers to recover resources
    without translation.
  * Receive arrays of resources.
  * Return an array with hashes of remote_translations values for
    every resources that have not translations.
  * This array will be the param that will be sent from view to
    RemoteTranslationController for create remote translations instances.
2019-06-27 09:20:25 +02:00
Senén Rodero Rodríguez
264b3f0f82 Simpler calls to *_translatable shared specs
Enable translations interface setting inside shared specs when needed.

Co-Authored-By: javierm <javim@elretirao.net>
2019-06-27 09:20:25 +02:00
Senén Rodero Rodríguez
73563e5d86 Display needed translations when translation interface is disabled
Display only current locale translation when translation interface is disabled.

Co-Authored-By: javierm <javim@elretirao.net>
2019-06-27 09:20:25 +02:00
Senén Rodero Rodríguez
b5663a7c17 Add translation interface setting values
* Disable translation interface by default
 * Also add rake task to enable translations interface through rake
   command
2019-06-27 09:20:25 +02:00
Senén Rodero Rodríguez
7e3f0b5c18 Add translation interface feature setting
Allow to enable/disable translation interface at frontend
2019-06-27 09:20:25 +02:00
Senén Rodero Rodríguez
3176be43d9 Rename "translatable" shared example to "edit_translatable"
Also rename all specs calls
2019-06-27 09:20:25 +02:00
Senén Rodero Rodríguez
64bfab9c9c Extract spec methods to commons module to avoid code duplication
Because "translatable" and "new_translatable" shared examples needs same methods to manipulate translations.
2019-06-27 09:20:25 +02:00
Senén Rodero Rodríguez
d0bf0f8857 Add "new_translatable" shared example to proposals feature specs 2019-06-27 09:20:25 +02:00
Senén Rodero Rodríguez
1bcbcf4975 Add "new_translatable" shared example to debates feature specs 2019-06-27 09:20:25 +02:00
Senén Rodero Rodríguez
1abcd95441 Add "new_translatable" shared example to budget investments feature specs 2019-06-27 09:20:25 +02:00
Senén Rodero Rodríguez
673fecf92a Add "new_translatable" shared example to check creation of translatable records
The existing shared example 'translatable' only works for edit actions.
This shared example allow us to check how translations behaves at new
resource pages.

Now this shared specs only works with Proposals, Budget::Investments and
Debates.
2019-06-27 09:20:24 +02:00
taitus
44ef1ce5e1 Fix houncibot parse error
Add missing quotes.

Notification Error:
warning: 2.6.0-dev-compliant syntax, but you are running 2.6.1.
warning: please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.
2 error(s) were found in ERB files
expected attribute value after '=' (at >)
2019-06-27 09:20:24 +02:00
Senén Rodero Rodríguez
1565a5a71d Fix most of Hound offenses 2019-06-27 09:20:24 +02:00
Senén Rodero Rodríguez
522b1c9ef7 Add budget investment translations to dev_seeds
Update budget investments development seeds with translations for all avaialble locales.
2019-06-27 09:20:24 +02:00
Senén Rodero Rodríguez
f116477d6d Enable soft_deletion of Budget::Investment::Translations 2019-06-27 09:20:24 +02:00
Senén Rodero Rodríguez
ef786d0658 Fix hidden budget investments restore feature
Add recursive restore option to restore all soft deleted relations.
2019-06-27 09:20:24 +02:00
Senén Rodero Rodríguez
e8f53cb8b7 Add translations to budget investments pg_search_scope
Some Budget::Investment attributes are now translatable so we need to
include all existing translations on pg_search model scope.
2019-06-27 09:20:24 +02:00
Senén Rodero Rodríguez
9a459070e9 Fix budget investment suggest feature 2019-06-27 09:20:24 +02:00
Senén Rodero Rodríguez
661ca5a568 Add budget investments translation interface
* Adapt translatable spec helper method to work with budget investments
* Remove old attributes from strong parameters
* Add missing locales to admin.yml and budgets.yml
* Change SpendingProposal.title_max_length and
  SpendingProposal.description_max_lenght to Budget::Investment methods
* Add budget investment translatable attribute translations
2019-06-27 09:20:24 +02:00
Senén Rodero Rodríguez
5eb5f02cbe Fix budget investment specs
After adding investment translatable fields to forms, they will be
generated with nested translations names and ids so we can no longer
use standard id locator.

Using input label text to fill in fields works with both types of forms.
2019-06-27 09:20:24 +02:00
Senén Rodero Rodríguez
88ce8d7990 Add sanitization shared spec to budget investment 2019-06-27 09:20:24 +02:00
Senén Rodero Rodríguez
eb2e402a92 Fix budget investments sorting by title
As we cannot order budget investments by any translatable field through
AR queries we are doing the same using ruby Array sort method and doing
array pagination manually with Kaminari 'paginate_array' helper method.
2019-06-27 09:20:24 +02:00
Senén Rodero Rodríguez
bb2ee6dd3c Fix search_by_title_or_id method
Results were not including records without translations for current
locale (I18n.locale). Now we search for given title against all
translation fallbacks for current locale.
2019-06-27 09:20:24 +02:00
Senén Rodero Rodríguez
66f885f8e4 Rename deprecated attributes in budget investments
To avoid deprecation warning thrown by Globalize after gem update. We
are going to keep these attributes with different names until next
release when we will be able to destroy them.
2019-06-27 09:20:24 +02:00
Senén Rodero Rodríguez
eefb9ca4f7 Add budget investment translations
Also fix sort_by_title method [1]

[1] Use ruby sort instead of active record order scope because Globalize
does not provide a way to search over all available fallbacks when
translation for current locale does not exist.
2019-06-27 09:20:24 +02:00
Senén Rodero Rodríguez
8c2f1b894d Add controller concern to initialize Globalize fallbacks
Ensure to initialize all requests including this concern into all
application base controllers.
2019-06-27 09:20:24 +02:00
Senén Rodero Rodríguez
0011a0b4c7 Move Translation class inside Budget
The reason to move Translation class is explained here [1]

[1] 106649a8a5
2019-06-27 09:20:24 +02:00
Senén Rodero Rodríguez
3b03e583f9 Move Translation class inside Budget::Phase
The reason to move Translation class is explained here [1]

[1] 106649a8a5
2019-06-27 09:19:37 +02:00
Senén Rodero Rodríguez
27f6c8804f Move Translation class inside Budget::Heading
The reason to move Translation class is explained here [1]

[1] 106649a8a5
2019-06-27 09:19:37 +02:00
Senén Rodero Rodríguez
c2f393276a Move Translation class inside Budget::Group
The reason to move Translation class is explained here [1]

[1] 106649a8a5
2019-06-27 09:19:37 +02:00
Senén Rodero Rodríguez
da1c5fdb01 Remove unneded before validation callbacks
After globalize gem update there is no need to keep this monkey patch.

More information here [1]

[1] 3075c89b70
2019-06-27 09:19:37 +02:00