From aed5ed624b34df80657496d47a291c46c200e724 Mon Sep 17 00:00:00 2001 From: Juan Artero Date: Tue, 6 Nov 2018 11:24:40 +0100 Subject: [PATCH 1/8] Improve Develop environment --- .gitignore | 1 + bin/rspec | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100755 bin/rspec diff --git a/.gitignore b/.gitignore index b2406ac..fdff369 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ *.rbc .bundle .config +.vscode Gemfile.lock .bundle/ log/*.log diff --git a/bin/rspec b/bin/rspec new file mode 100755 index 0000000..a6c7852 --- /dev/null +++ b/bin/rspec @@ -0,0 +1,29 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +# +# This file was generated by Bundler. +# +# The application 'rspec' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require "pathname" +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", + Pathname.new(__FILE__).realpath) + +bundle_binstub = File.expand_path("../bundle", __FILE__) + +if File.file?(bundle_binstub) + if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/ + load(bundle_binstub) + else + abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. +Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") + end +end + +require "rubygems" +require "bundler/setup" + +load Gem.bin_path("rspec-core", "rspec") From 540faf1840450b35d67b5ebe28bccf6353b5467c Mon Sep 17 00:00:00 2001 From: Juan Artero Date: Tue, 6 Nov 2018 12:06:19 +0100 Subject: [PATCH 2/8] Fix fech_all_phases to work with different backends --- lib/rosetta.rb | 33 ++++++------ lib/rosetta/backend_extras.rb | 80 +++++++++++++++++++++++++++++ spec/rosetta/backend_extras_spec.rb | 33 ++++++++++++ 3 files changed, 131 insertions(+), 15 deletions(-) create mode 100644 lib/rosetta/backend_extras.rb create mode 100644 spec/rosetta/backend_extras_spec.rb diff --git a/lib/rosetta.rb b/lib/rosetta.rb index e26c185..e4524ab 100644 --- a/lib/rosetta.rb +++ b/lib/rosetta.rb @@ -12,6 +12,8 @@ require 'rosetta/repository' require 'rosetta/controller_additions' +require 'rosetta/backend_extras' + require 'rosetta/repositories/database' require 'rosetta/repositories/local' require 'rosetta/repositories/onesky' @@ -30,11 +32,14 @@ def add_phrase(**args) end def fetch_all_phrases(locale: I18n.default_locale) - translations = I18n.backend.translations(do_init: true).fetch(locale.to_sym, {}) + backend_extra = backend_extras - I18n.with_locale(locale.to_sym) do - [].tap { |phrases| build_phrases_from_translations(translations, phrases) } + output = [] + backend_extra.translates_list(locale: locale).each do |key, value| + repository_link = config.repository.build_link(key.split('.'), locale: locale) + output << Phrase.new(key.split('.'), value, repository_link) end + output end def phrases @@ -59,18 +64,6 @@ def disable private - def build_phrases_from_translations(translations, phrases, current_key = []) - translations.each do |key, value| - if value.is_a? Hash - build_phrases_from_translations(value, phrases, current_key + [key]) - else - next if value.blank? - - phrases << build_phrase(keys: current_key + [key], phrase: value) - end - end - end - def build_phrase(**args) fail ArgumentError, 'missing keys argument' if args[:keys].blank? fail ArgumentError, 'missing phrase argument' if args[:phrase].blank? @@ -91,6 +84,16 @@ def request RequestStore.store[:rosetta] ||= {} end + def backend_extras + if backend.class == I18n::Backend::ActiveRecord + BackendExtras::ActiveRecord.new + elsif backend.class == I18n::Backend::Simple + BackendExtras::Simple.new + elsif backend.class == I18n::Backend::Chain + BackendExtras::Chain.new + end + end + end end diff --git a/lib/rosetta/backend_extras.rb b/lib/rosetta/backend_extras.rb new file mode 100644 index 0000000..c733df3 --- /dev/null +++ b/lib/rosetta/backend_extras.rb @@ -0,0 +1,80 @@ +# frozen_string_literal: true + +module Rosetta + module BackendExtras + class Base + + attr_reader :backend + + def initialize(backend: I18n.backend) + @backend = backend + end + + end + + class Simple < Base + + def translates_list(locale: I18n.default_locale) + translations = backend.translations(do_init: true).fetch(locale.to_sym, {}) + + {}.tap { |phrases| build_phrases_from_translations(translations, phrases) } + end + + private + + def build_phrases_from_translations(translations, phrases, current_key = []) + translations.each do |key, value| + if value.is_a? Hash + build_phrases_from_translations(value, phrases, current_key + [key]) + else + next if value.blank? + + phrases[(current_key + [key]).join('.')] = value + end + end + end + + end + + class ActiveRecord < Base + + def translates_list(locale: I18n.default_locale) + {}.tap do |phrases| + translation_klass.where(locale: locale).find_each do |translation| + phrases[translation.key] = translation.value + end + end + end + + private + + def translation_klass + I18n::Backend::ActiveRecord::Translation + end + + end + + class Chain < Base + + def translates_list(locale: I18n.default_locale) + output = {} + backend.backends.reverse_each do |chained_backend| + output = output.merge(backend_factory(chained_backend) + .translates_list(locale: locale)) + end + output + end + + private + + def backend_factory(backend_to_factory) + if backend_to_factory.class == I18n::Backend::ActiveRecord + ActiveRecord.new(backend: backend_to_factory) + elsif backend_to_factory.class == I18n::Backend::Simple + Simple.new(backend: backend_to_factory) + end + end + + end + end +end diff --git a/spec/rosetta/backend_extras_spec.rb b/spec/rosetta/backend_extras_spec.rb new file mode 100644 index 0000000..262ce77 --- /dev/null +++ b/spec/rosetta/backend_extras_spec.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Rosetta::BackendExtras::Simple do + describe '.translates_list' do + it do + expect(described_class.new(backend: I18n::Backend::Simple.new).translates_list['samples.index.hello']).to eq 'Hello world!!' + end + end +end + +RSpec.describe Rosetta::BackendExtras::ActiveRecord do + describe '.translates_list' do + it do + I18n::Backend::ActiveRecord::Translation.create(locale: 'en', key: 'samples.goodbye', value: 'Goodbye!!') + expect(described_class.new(backend: I18n::Backend::ActiveRecord.new).translates_list['samples.goodbye']).to eq 'Goodbye!!' + end + end +end + +RSpec.describe Rosetta::BackendExtras::Chain do + describe '.translates_list' do + it do + I18n::Backend::ActiveRecord::Translation.create(locale: 'en', key: 'samples.goodbye', value: 'Goodbye!!') + I18n::Backend::ActiveRecord::Translation.create(locale: 'en', key: 'samples.index.hello', value: 'Hi!!') + backend = I18n::Backend::Chain.new(I18n::Backend::ActiveRecord.new, I18n::Backend::Simple.new) + + expect(described_class.new(backend: backend).translates_list['samples.index.hello']).to eq 'Hi!!' + expect(described_class.new(backend: backend).translates_list['samples.goodbye']).to eq 'Goodbye!!' + end + end +end From 2f5ed3e7d4400df5a0a90ef0a46311a695262d1d Mon Sep 17 00:00:00 2001 From: Juan Artero Date: Tue, 6 Nov 2018 12:06:41 +0100 Subject: [PATCH 3/8] Fix dummy initializer --- spec/dummy/config/initializers/rosetta.rb | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/spec/dummy/config/initializers/rosetta.rb b/spec/dummy/config/initializers/rosetta.rb index bc3a897..4e02df7 100644 --- a/spec/dummy/config/initializers/rosetta.rb +++ b/spec/dummy/config/initializers/rosetta.rb @@ -1,24 +1,25 @@ +# frozen_string_literal: true + require 'i18n/backend/active_record' # Use this hook to configure the repository and other Rosetta options. -Rosetta.setup do |_config| +Rosetta.setup do |config| # Uncomment the following lines to use the OneSky repository. # config.repository = Rosetta::Repositories::Onesky # config.onesky.project_id = ENV['ONESKY_PROJECT_ID'] # config.onesky.subdomain = ENV['ONESKY_SUBDOMAIN'] # Uncomment the following lines to use the Local repository. - # config.repository = Rosetta::Repositories::Local -end - -Translation = I18n::Backend::ActiveRecord::Translation + config.repository = Rosetta::Repositories::Database.new + Translation = I18n::Backend::ActiveRecord::Translation -if Translation.table_exists? - I18n.backend = I18n::Backend::ActiveRecord.new + if Translation.table_exists? + I18n.backend = I18n::Backend::ActiveRecord.new - I18n::Backend::ActiveRecord.send(:include, I18n::Backend::Memoize) - I18n::Backend::Simple.send(:include, I18n::Backend::Memoize) - I18n::Backend::Simple.send(:include, I18n::Backend::Pluralization) + I18n::Backend::ActiveRecord.send(:include, I18n::Backend::Memoize) + I18n::Backend::Simple.send(:include, I18n::Backend::Memoize) + I18n::Backend::Simple.send(:include, I18n::Backend::Pluralization) - I18n.backend = I18n::Backend::Chain.new(I18n.backend, I18n::Backend::Simple.new) + I18n.backend = I18n::Backend::Chain.new(I18n.backend, I18n::Backend::Simple.new) + end end From 3dc1a54531ebc0f54afababd941299a3e3c52a40 Mon Sep 17 00:00:00 2001 From: Juan Artero Date: Tue, 6 Nov 2018 12:23:17 +0100 Subject: [PATCH 4/8] Move styles to scss --- .../stylesheets/rosetta/application.css | 205 ----------------- .../stylesheets/rosetta/application.scss | 2 + .../rosetta/blocks/_pharses-menu.scss | 209 ++++++++++++++++++ .../rosetta/blocks/_phrases-list.scss | 9 + lib/rosetta.rb | 1 + rosetta.gemspec | 3 + 6 files changed, 224 insertions(+), 205 deletions(-) delete mode 100644 app/assets/stylesheets/rosetta/application.css create mode 100644 app/assets/stylesheets/rosetta/application.scss create mode 100644 app/assets/stylesheets/rosetta/blocks/_pharses-menu.scss create mode 100644 app/assets/stylesheets/rosetta/blocks/_phrases-list.scss diff --git a/app/assets/stylesheets/rosetta/application.css b/app/assets/stylesheets/rosetta/application.css deleted file mode 100644 index 94c3194..0000000 --- a/app/assets/stylesheets/rosetta/application.css +++ /dev/null @@ -1,205 +0,0 @@ -.phrases-menu { - height: 100%; - width: 350px; - position: fixed; - z-index: 1000; - top: 0; - font-family: Arial, Helvetica, sans-serif; - left: -350px; - background-color: #F5F5F5; - transition: 0.2s; - -webkit-box-shadow: 3px 4px 6px 0 rgba(0, 0, 0, 0.2); - box-shadow: 3px 4px 6px 0 rgba(0, 0, 0, 0.2); -} - -.phrases-menu.match-phrase, -.phrases-menu.match-phrase .open-phrases-menu-btn { - background-color: #eaffdd; -} - -.phrases-menu.match-phrase .phrases-menu__block { - background-color: #f7fff3; -} - -.phrases-menu.unmatch-phrase, -.phrases-menu.unmatch-phrase .open-phrases-menu-btn { - background-color: #fae0dd; -} - -.phrases-menu.open { - left: 0px; -} - -.phrases-menu__header { - height: 45px; - position: relative; -} - -.phrases-menu__content { - height: calc(100% - 46px); - padding: 2px 0 12px 0; - overflow: auto; - box-sizing: border-box; -} - -.phrases-menu__title { - margin: 0; - padding: 12px 9px; - font-size: 18px; - text-transform: uppercase; - border-bottom: 1px solid #dedede; -} - -.phrases-menu__list { - margin-left: 10px; - margin-right: 10px; -} - -.phrases-menu__block { - color: #000000; - display: block; - text-decoration: none; - padding: 10px 10px; - transition: 0.3s; - font-size: 12px; - margin-top: 10px; - border-radius: 3px; - background: #ffffff; - border: 1px solid #dedede; -} - -.phrases-menu__block.hide { - display: none; -} - -.phrases-menu:not(.local) .phrases-menu__block:hover { - color: #e81d08; - cursor: pointer; - border: 1px solid #e81d08; - text-decoration: none; -} - -.phrases-menu__key { - font-size: 12px; - font-weight: 900; - margin-bottom: 11px; -} - -.phrases-menu__phrase { - font-size: 13px; - margin-bottom: 11px; -} - -.phrases-menu__phrase:last-child { - margin-bottom: 0; -} - -.phrases-menu__path { - font-size: 12px; - color: #9a9a9a; - transition: 0.3s; -} - -.phrases-menu:not(.local) .phrases-menu__block:hover .phrases-menu__path { - color: #e81d08; -} - -.phrases-menu__footer { - text-align: center; - max-width: 75%; - margin: 25px auto 0; -} - -.phrases-menu__footer h1 { - font-size: 18px; - color: #7b7b7b; -} - -.phrases-menu__footer p { - font-size: 12px; - color: #9a9a9a; - line-height: 1.4; -} - -.phrases-menu__footer a { - color: inherit; -} - -.phrases-menu__footer a:hover { - color: #e81d08; -} - -.open-phrases-menu-btn { - background-color: #F5F5F5; - color: #686866; - -webkit-box-shadow: 4px 3px 5px 0 rgba(0, 0, 0, 0.2); - box-shadow: 4px 3px 5px 0 rgba(0, 0, 0, 0.2); - display: block; - position: absolute; - right: -55px; - height: 45px; - width: 55px; - border-radius: 0 0 3px 0; - top: 0px; - cursor: pointer; -} - -.phrases-menu__closebtn { - transition: 0.3s; - display: none; -} - -.phrases-menu.open .phrases-menu__closebtn { - display: block; -} - -.phrases-menu.open .phrases-menu__openbtn { - display: none; -} - -.phrases-menu__closebtn img { - height: 20px; - position: absolute; - top: 50%; - left: 50%; - -webkit-transform: translate(-50%, -50%); - -ms-transform: translate(-50%, -50%); - transform: translate(-50%, -50%); -} - -.phrases-menu__intro { - padding-left: 16px; - margin-bottom: 0; - font-size: 14px -} - -.phrases-menu__search { - font-size: 14px; - padding: 9px 16px; - color: #807e7e; -} - -.phrases-list__search { - max-width: 100%; - padding: 16px; -} - -.phrases-list__search input { - width: 100%; - font-size: 24px; -} - -.phrases-menu__openbtn img { - height: 30px; - position: absolute; - top: 50%; - left: 50%; - -webkit-transform: translate(-50%, -50%); - -ms-transform: translate(-50%, -50%); - transform: translate(-50%, -50%); -} - -.database__field { - min-width: 100%; - max-height: 150px important !; -} diff --git a/app/assets/stylesheets/rosetta/application.scss b/app/assets/stylesheets/rosetta/application.scss new file mode 100644 index 0000000..2373155 --- /dev/null +++ b/app/assets/stylesheets/rosetta/application.scss @@ -0,0 +1,2 @@ +@import 'blocks/pharses-menu'; +@import 'blocks/phrases-list'; \ No newline at end of file diff --git a/app/assets/stylesheets/rosetta/blocks/_pharses-menu.scss b/app/assets/stylesheets/rosetta/blocks/_pharses-menu.scss new file mode 100644 index 0000000..ab8368b --- /dev/null +++ b/app/assets/stylesheets/rosetta/blocks/_pharses-menu.scss @@ -0,0 +1,209 @@ +.phrases-menu { + height: 100%; + width: 350px; + position: fixed; + z-index: 1000; + top: 0; + font-family: Arial, Helvetica, sans-serif; + left: -350px; + background-color: #F5F5F5; + transition: 0.2s; + -webkit-box-shadow: 3px 4px 6px 0 rgba(0, 0, 0, 0.2); + box-shadow: 3px 4px 6px 0 rgba(0, 0, 0, 0.2); + + &__header { + height: 45px; + position: relative; + } + + &__title { + margin: 0; + padding: 12px 9px; + font-size: 18px; + text-transform: uppercase; + border-bottom: 1px solid #dedede; + } + + &__intro { + padding-left: 16px; + margin-bottom: 0; + font-size: 14px + } + + &__search { + font-size: 14px; + padding: 9px 16px; + color: #807e7e; + } + + &__block { + background-color: #f7fff3; + color: #000000; + display: block; + text-decoration: none; + padding: 10px 10px; + transition: 0.3s; + font-size: 12px; + margin-top: 10px; + border-radius: 3px; + background: #ffffff; + border: 1px solid #dedede; + + &.hide { + display: none; + } + } + + &__content { + height: calc(100% - 46px); + padding: 2px 0 12px 0; + overflow: auto; + box-sizing: border-box; + } + + &__list { + margin-left: 10px; + margin-right: 10px; + } + + &__key { + font-size: 12px; + font-weight: 900; + margin-bottom: 11px; + } + + &__phrase { + font-size: 13px; + margin-bottom: 11px; + + &:last-child { + margin-bottom: 0; + } + } + + &__path { + font-size: 12px; + color: #9a9a9a; + transition: 0.3s; + } + + &__footer { + text-align: center; + max-width: 75%; + margin: 25px auto 0; + + h1 { + font-size: 18px; + color: #7b7b7b; + } + + p { + font-size: 12px; + color: #9a9a9a; + line-height: 1.4; + } + + a { + color: inherit; + &:hover { + color: #e81d08; + } + } + } + + &__openbtn { + img { + height: 30px; + position: absolute; + top: 50%; + left: 50%; + -webkit-transform: translate(-50%, -50%); + -ms-transform: translate(-50%, -50%); + transform: translate(-50%, -50%); + } + } + + &__closebtn { + transition: 0.3s; + display: none; + + img { + height: 20px; + position: absolute; + top: 50%; + left: 50%; + -webkit-transform: translate(-50%, -50%); + -ms-transform: translate(-50%, -50%); + transform: translate(-50%, -50%); + } + } + + + + &.match-phrase { + background-color: #eaffdd; + + .phrases-menu__block { + background-color: #eaffdd; + } + + .open-phrases-menu-btn { + background-color: #eaffdd; + } + } + + &.unmatch-phrase { + background-color: #fae0dd; + + .phrases-menu__block { + background-color: #fae0dd; + } + + .open-phrases-menu-btn { + background-color: #fae0dd; + } + } + + &.open { + left: 0px; + + .phrases-menu__closebtn { + display: block; + } + + .phrases-menu__openbtn { + display: none; + } + } + +} + +// Extras +.open-phrases-menu-btn { + background-color: #F5F5F5; + color: #686866; + -webkit-box-shadow: 4px 3px 5px 0 rgba(0, 0, 0, 0.2); + box-shadow: 4px 3px 5px 0 rgba(0, 0, 0, 0.2); + display: block; + position: absolute; + right: -55px; + height: 45px; + width: 55px; + border-radius: 0 0 3px 0; + top: 0px; + cursor: pointer; +} + +.phrases-menu:not(.local) .phrases-menu__block:hover { + color: #e81d08; + cursor: pointer; + border: 1px solid #e81d08; + text-decoration: none; +} + +.phrases-menu:not(.local) .phrases-menu__block:hover .phrases-menu__path { + color: #e81d08; +} + + + diff --git a/app/assets/stylesheets/rosetta/blocks/_phrases-list.scss b/app/assets/stylesheets/rosetta/blocks/_phrases-list.scss new file mode 100644 index 0000000..be2ea1a --- /dev/null +++ b/app/assets/stylesheets/rosetta/blocks/_phrases-list.scss @@ -0,0 +1,9 @@ +.phrases-list__search { + max-width: 100%; + padding: 16px; +} + +.phrases-list__search input { + width: 100%; + font-size: 24px; +} diff --git a/lib/rosetta.rb b/lib/rosetta.rb index e4524ab..0a1426e 100644 --- a/lib/rosetta.rb +++ b/lib/rosetta.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require 'i18n' +require 'sass-rails' require 'request_store' require 'rosetta/core_ext/dig' diff --git a/rosetta.gemspec b/rosetta.gemspec index adf2ab3..1d06aac 100644 --- a/rosetta.gemspec +++ b/rosetta.gemspec @@ -1,3 +1,5 @@ +# frozen_string_literal: true + $:.push File.expand_path('lib', __dir__) require 'rosetta/version' @@ -15,6 +17,7 @@ Gem::Specification.new do |s| s.files = Dir['{app,config,db,lib}/**/*', 'MIT-LICENSE', 'Rakefile', 'README.md'] s.add_dependency 'rails' + s.add_dependency 'sass-rails' s.add_dependency 'request_store' # Development/Test dependencies From 930bde647e85661a8c77c3e30ec86b39492c0cb4 Mon Sep 17 00:00:00 2001 From: Juan Artero Date: Tue, 6 Nov 2018 12:43:43 +0100 Subject: [PATCH 5/8] Refactor views to work with VueJS --- app/assets/javascripts/rosetta/application.js | 23 +++++- .../rosetta/vendor/autosize.min.js | 6 ++ app/views/rosetta/_footer.html.erb | 5 ++ app/views/rosetta/_phrases_list.html.erb | 9 +++ app/views/rosetta/_translate_menu.html.erb | 76 +++---------------- app/views/rosetta/database/_actions.html.erb | 12 --- app/views/rosetta/database/_actions_vue.html | 8 -- .../rosetta/database/_actions_vue.html.erb | 20 +++++ .../database/_additional_actions.html.erb | 1 + app/views/rosetta/local/_actions.html.erb | 13 ---- app/views/rosetta/onesky/_actions.html.erb | 11 --- app/views/rosetta/phrases/index.html.erb | 10 +-- lib/rosetta/controller_additions.rb | 6 ++ 13 files changed, 81 insertions(+), 119 deletions(-) create mode 100755 app/assets/javascripts/rosetta/vendor/autosize.min.js create mode 100644 app/views/rosetta/_footer.html.erb create mode 100644 app/views/rosetta/_phrases_list.html.erb delete mode 100644 app/views/rosetta/database/_actions.html.erb delete mode 100644 app/views/rosetta/database/_actions_vue.html create mode 100644 app/views/rosetta/database/_actions_vue.html.erb create mode 100644 app/views/rosetta/database/_additional_actions.html.erb delete mode 100644 app/views/rosetta/local/_actions.html.erb delete mode 100644 app/views/rosetta/onesky/_actions.html.erb diff --git a/app/assets/javascripts/rosetta/application.js b/app/assets/javascripts/rosetta/application.js index 40a99f3..cc97af3 100644 --- a/app/assets/javascripts/rosetta/application.js +++ b/app/assets/javascripts/rosetta/application.js @@ -1,13 +1,17 @@ //= require ./vendor/vue.min //= require ./vendor/lunr +//= require ./vendor/autosize.min function initPhrasesList(selector, phrases) { new Vue({ el: selector, + data: { phrases: phrases, - query: '' + query: '', + menuOpened: false, }, + computed: { searchIndex: function() { var that = this; @@ -17,14 +21,14 @@ function initPhrasesList(selector, phrases) { this.field('text'); that.phrases.forEach(function (phrase) { - this.add(phrase) + this.add(phrase); }, this); }); }, + filteredPhrases: function () { if (this.query) { var results = this.searchIndex.search(this.query); - return this.phrases.filter(function (phrase) { return results.some(function (result) { return result.ref === phrase.code; @@ -34,6 +38,19 @@ function initPhrasesList(selector, phrases) { return this.phrases; } } + }, + + updated: function () { + this.$nextTick(function () { + autosize(document.querySelectorAll('.database__field')); + }); + }, + + methods: { + toggleNav: function() { + this.menuOpened = this.menuOpened ? false : true; + console.log('toggleNav', this.menuOpened); + } } }); } diff --git a/app/assets/javascripts/rosetta/vendor/autosize.min.js b/app/assets/javascripts/rosetta/vendor/autosize.min.js new file mode 100755 index 0000000..4d9b4e9 --- /dev/null +++ b/app/assets/javascripts/rosetta/vendor/autosize.min.js @@ -0,0 +1,6 @@ +/*! + autosize 4.0.2 + license: MIT + http://www.jacklmoore.com/autosize +*/ +!function(e,t){if("function"==typeof define&&define.amd)define(["module","exports"],t);else if("undefined"!=typeof exports)t(module,exports);else{var n={exports:{}};t(n,n.exports),e.autosize=n.exports}}(this,function(e,t){"use strict";var n,o,p="function"==typeof Map?new Map:(n=[],o=[],{has:function(e){return-1 +

Rosetta

+

Rosetta is available as open source under the terms of the MIT License.

+

View in Github

+ \ No newline at end of file diff --git a/app/views/rosetta/_phrases_list.html.erb b/app/views/rosetta/_phrases_list.html.erb new file mode 100644 index 0000000..77448e4 --- /dev/null +++ b/app/views/rosetta/_phrases_list.html.erb @@ -0,0 +1,9 @@ +
+ + +
+ <%= render "rosetta/#{repository_id}/actions_vue" %> +
+
\ No newline at end of file diff --git a/app/views/rosetta/_translate_menu.html.erb b/app/views/rosetta/_translate_menu.html.erb index 11743ab..e56a58d 100644 --- a/app/views/rosetta/_translate_menu.html.erb +++ b/app/views/rosetta/_translate_menu.html.erb @@ -1,86 +1,34 @@ <% if rosetta? %> <%= stylesheet_link_tag 'rosetta/application' %> + <%= javascript_include_tag 'rosetta/application' %> -
-
+
+
<%= image_tag('rosetta/language_icon.svg') %>
+
<%= image_tag('rosetta/close.svg') %>
+

<%= Rosetta.repository.label %> [<%= Rosetta.locale %>]

+ <%= link_to 'All Phrases', rosetta.phrases_path %>
+
-

- Select any text in the page to search the corresponding translation. -

- -
-

<%= link_to 'View all phrases', rosetta.phrases_path, target: :blank %>

+ <%= render 'rosetta/phrases_list', repository_id: Rosetta.repository.id %> - <% Rosetta.phrases.each do |phrase| %> - <%= render "rosetta/#{Rosetta.repository.id}/actions", - phrase: phrase %> - <% end %> -
- + <%= render 'rosetta/footer' %>
- <% end %> diff --git a/app/views/rosetta/database/_actions.html.erb b/app/views/rosetta/database/_actions.html.erb deleted file mode 100644 index b4f8111..0000000 --- a/app/views/rosetta/database/_actions.html.erb +++ /dev/null @@ -1,12 +0,0 @@ -
-
- <%= phrase.code %> -
-
- <%= form_tag(rosetta.database_repository_phrase_path(id: phrase.code), method: :put, id: phrase.code) do %> - <%= hidden_field_tag(:current_path, url_for) %> - <%= text_area_tag(:value, phrase.text, id: "#{phrase.code}_value", class: 'database__field') %> - <%= submit_tag("Update", id: "#{phrase.code}_submit") %> - <% end %> -
-
diff --git a/app/views/rosetta/database/_actions_vue.html b/app/views/rosetta/database/_actions_vue.html deleted file mode 100644 index cc9826b..0000000 --- a/app/views/rosetta/database/_actions_vue.html +++ /dev/null @@ -1,8 +0,0 @@ -
-
- {{ phrase.code }} -
-
- TODO -
-
diff --git a/app/views/rosetta/database/_actions_vue.html.erb b/app/views/rosetta/database/_actions_vue.html.erb new file mode 100644 index 0000000..e3a1d86 --- /dev/null +++ b/app/views/rosetta/database/_actions_vue.html.erb @@ -0,0 +1,20 @@ +
+
+ {{ phrase.code }} +
+ +
+
+ + + <%= hidden_field_tag :authenticity_token, form_authenticity_token -%> + + + +
+
+ +
+ <%= render 'rosetta/database/additional_actions' %> +
+
diff --git a/app/views/rosetta/database/_additional_actions.html.erb b/app/views/rosetta/database/_additional_actions.html.erb new file mode 100644 index 0000000..9d697a4 --- /dev/null +++ b/app/views/rosetta/database/_additional_actions.html.erb @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/views/rosetta/local/_actions.html.erb b/app/views/rosetta/local/_actions.html.erb deleted file mode 100644 index 3f0bcec..0000000 --- a/app/views/rosetta/local/_actions.html.erb +++ /dev/null @@ -1,13 +0,0 @@ -
-
- <%= phrase.code %> -
- -
- <%= phrase.text %> -
- -
- <%= phrase.repository_link %> -
-
diff --git a/app/views/rosetta/onesky/_actions.html.erb b/app/views/rosetta/onesky/_actions.html.erb deleted file mode 100644 index 92e24b2..0000000 --- a/app/views/rosetta/onesky/_actions.html.erb +++ /dev/null @@ -1,11 +0,0 @@ -<%= link_to(phrase.repository_link, target: '_blank', class: 'phrases-menu__block') do %> -
-
- <%= phrase.code %> -
- -
- <%= phrase.text %> -
-
-<% end %> diff --git a/app/views/rosetta/phrases/index.html.erb b/app/views/rosetta/phrases/index.html.erb index e314ea0..dc53296 100644 --- a/app/views/rosetta/phrases/index.html.erb +++ b/app/views/rosetta/phrases/index.html.erb @@ -4,15 +4,9 @@
-
- +<%= render 'rosetta/phrases_list', repository_id: Rosetta.repository.id %> -
- <%= render "rosetta/#{Rosetta.repository.id}/actions_vue" %> -
-
+<%= render 'rosetta/footer' %>