๐ซ How to reach me: dylans @ gmail
dylanz / i18n_backend_database Goto Github PK
View Code? Open in Web Editor NEWDatabase Backend for Rails I18n
License: Other
Database Backend for Rails I18n
License: Other
When we parse tlt tags, we translate anything in-between the set tag, ie: ^^this will be translated^^. However, we will incorrectly try and parse this ^^^^. Our regex should account for these cases, and require included content.
To replicate:
Place this somewhere in the /app directory:
I18n.t('activerecord.errors.messages.record_invalid', :errors => "test test test")
Run the "I18n:populate:from_rails" rake task. The regular expressions grabs the key, but not the interpolation arguments, which it should.
terminal output:
rails g i18n_backend_database
$HOME/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.3/lib/active_record/base.rb:1088:in `method_missing': undefined method `named_scope' for #<Class:0xa050d5c> (NoMethodError)ax
from $HOME/.rvm/gems/ruby-1.9.2-p290/gems/i18n_backend_database-0.0.1/lib/models/locale.rb:6:in `<class:Locale>'
from $HOME/.rvm/gems/ruby-1.9.2-p290/gems/i18n_backend_database-0.0.1/lib/models/locale.rb:1:in `<top (required)>'
from $HOME/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in `require'
from $HOME/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in `block in require'
from $HOME/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:223:in `block in load_dependency'
from $HOME/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:640:in `new_constants_in'
from $HOME/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:223:in `load_dependency'
from $HOME/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in `require'
from $HOME/.rvm/gems/ruby-1.9.2-p290/gems/i18n_backend_database-0.0.1/lib/i18n_backend_database.rb:1:in `<top (required)>'
from $HOME/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `require'
from $HOME/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
from $HOME/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `each'
from $HOME/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `block in require'
from $HOME/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `each'
from $HOME/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `require'
from $HOME/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.0.21/lib/bundler.rb:122:in `require'
from /media/PORT/work/couture/config/application.rb:13:in `<top (required)>'
from $HOME/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.3/lib/rails/commands.rb:21:in `require'
from $HOME/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.3/lib/rails/commands.rb:21:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
Hi there,
Awesome gem. Is there any rails 3 support planned for it?
Or do you know a way to get it to work?
Many thanks
Wijnand
Hello,
I am trying to import my translations into database with rake i18n:populate:from_application but the task is always interrupted by an interpolation argument error:
interpolation argument product missing in "{{product}} {{version}} released!"
In application, the translation is used several times:
text = I18n.t('txt.home.new_release', :product => product_name, :version => version)
xml.title t('txt.home.new_release', :product => post.product_name, :version => post.version)
<%= t('txt.home.new_release', :product => latest.product_name, :version => latest.version) %>
All the interpolation arguments are correct and a whole bunch of other translations with interpolation arguments is being imported without a problem. Am I missing something?
Thanks!
Currently, the two provided controllers let anyone and everyone access them, and require some fiddling to secure. It would be better to make them secure by default.
I18n defines a Locale module,
This messes up the access to the plugin's Locale Class...
All the methods the are called from the Database instance like available_locales fails because they are trying to reach Locale module instead of the Locale class
create_seed_translations should look for I18n.translate as well as I18n.t. It looks for the alias, but not the first class method.
We're running Rails 2.3.5, not sure if something changed in there. The problem has to do with some of the stuff in this commit http://github.com/dylanz/i18n_backend_database/commit/e1faa3f384daf26b2809aadfdb4f86569615497f
What I was seeing is the object that was being scanned for interpolation arguments looking something like this:
"'activerecord.errors.messages.record_invalid', :errors=>errors"
and not being able to parse out the fact that it needs an errors option. My regex_fu is limited so I haven't been able to come up with something better.
Why did you release this under such a strange license?
I'd use this, but requiring all companies to display "This product includes software developed by ELC Technologies" seems excessive.
Would you reconsider releasing this under a more standard open license (MIT, BSD, GPL)?
'string' ends up being 255 chars, which is not enough for longer bits of text.
create_table :translations do |t|
t.string :key
- t.string :raw_key
- t.string :value
+ t.text :raw_key
+ t.text :value
t.integer :pluralization_index, :default => 1
t.integer :locale_id
end
There should also be a little bit more room in the translation workspace:
--- a/lib/views/translations/translations.html.erb
+++ b/lib/views/translations/translations.html.erb
@@ -19,7 +19,7 @@
<% remote_form_for([@locale, translation]) do |f| %>
<p><%=h translation.default_locale_value || translation.raw_key %></p>
<p>
- <%= f.text_field :value %>
+ <%= f.text_field :value, :size => 128 %>
<%= f.submit "Update" %>
</p>
<% end %>
That could also be made to be a bit 'clever', and use a text area for larger bits of text...
We are interested in using this software but we need to know what the license is. MIT? Pretty much any non GPLish would be great.
Geoff
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.