Every repository with this icon (
Every repository with this icon (
| Description: | The second incarnation of Globalize for Rails edit |
-
We ran into a problem where the rails formbuilder wasn't pulling out our translated attributes. We finally tracked this down to the method #{attr}_before_type_cast, which wasn't returning the translated field.
Here is the patch and test that fixed the problem for us, hope it helps!
Comments
-
Create a migration script for Globalize1 / Rails 2.1 users
1 comment Created 6 months ago by tomashAt the moment installing Globalize2 pretty much cripples an application with Globalize1 db and cannot be easily migrated (relevant fields/columns are not accessible).
A migration script (rake task?) that'd seamlessly transfer existing Globalize1 translations (minus the default records) to a Globalize2 translations -- would be great.
Comments
I've hacked a migration script that pretty much works for me considering model-translations migration from Globalize1 to Globalize2
-
Using create_translation_table on a working application
0 comments Created 5 months ago by albertllopWould be nice to have something to get better migrations when you already have some elements of a model you want to add globalize2 support.
The table is created, but the current entries won't show anything on the translated fields. Also, the original field isn't destroyed, which might create problems.
What we do is iterate through the current elements creating entries on all the locales, and then destroy the original attribute.
Comments
-
When you want to use _was dirty method on a translated field, it gives no method error in first run, nil on second run and correct value for a third run as below:
c = Category.last c.name_was NoMethodError: undefined method `name_was' c.name =>"Category Name" c.name_was NoMethodError: undefined method `name_was' c.name = "New Name" => "New Name" c.name_was => nil c.save => true c.name_was => "New Name"
Comments
-
makes sure interpolation does not break even with False as string
0 comments Created 3 months ago by karesthere's a test with this issue's "title" name however it's not testing what it should be.
it seems that the current implementation of the static backend is not compatible with the default simple backend in cases where the I18n.translate should return a true or false value, I have fixed the backend and added these tests :
the static backend fix and the tests are available in my globalize2 fork :
Comments
-
I'm using Rails 2.3.3 and have an irregular pluralization for curriculum and globalize2 is inadvertantly messing up the pluralization. In this example, I have a model named "TranslatedCurriculum" with table named "translated_curricula" and a model named "UntranslatedCurriculum" with a table named "untranslated_curricula". The TranslatedCurriculum has model translations, the UntranslatedCurriculum does not. If I boot up a console, I'll get the following:
>> TranslatedCurriculum.table_name => "translated_curriculums" >> UntranslatedCurriculum.table_name => "untranslated_curricula"Notice that the TranslatedCurriculum is wrong (this leads to no queries working...). The reason for this problem is that the translates() method in globalize2 is causing 'table_name' to be called on the TranslatedCurriculum object, thereby causing the table_name to be set for all time, since base.rb eventually calls set_table_name, which is defined as
def set_table_name(value = nil, &block) define_attr_method :table_name, value, &block endSince the irregular inflections haven't been loaded at this point, the incorrect inflection is saved.
I was able to fix this by patching the translates() method to have the following at the bottom of the method:
define_attr_method :table_name do reset_table_name endwhich will mean that the table_name will be set at a later point in time (hopefully when the inflections have been loaded).
If you're trying to reproduce this, my environment.rb had the following block:
ActiveSupport::Inflector.inflections do |inflect| inflect.irregular 'curriculum', 'curricula' endComments
-
I'm using Rails 2.3.4 and latest version of Globalize2.
Don't know how to describe the issue, so here are the facts.
In globalize2/lib/globalize/model/active_record.rb on line 16:
belongs_to "#{klass.name.underscore.gsub('/', '_')}".internBut SomeModelTranslation.reflect_on_all_associations returns []
If I add
self.globalize_proxy.belongs_to "#{self.name.underscore.gsub('/', '_')}".internafter line 27 in globalize2/lib/globalize/model/active_record/translated.rb, or simply envoke
SomeModelTranslation.belongs_to :some_modelthen association builds properly.
Comments
-
create_translation_table! doesn't work correctly when I set a table prefix in my environment.rb:
config.active_record.table_name_prefix= '_'here's my solution:
in file lib/globalize/model/active_record.rb
changeself.connection.create_table(translation_table_name) do |t|with
self.connection.create_table("#{table_name_prefix}#{translation_table_name}#{table_name_suffix}") do |t|bye
Devis_
Comments
-
Broken session with Globalize::Translation::Static
2 comments Created about 1 month ago by alexeypetrushinGlobalize2 uses Globalize::Translation::Static instead of String. So, if you save such translated string in session (flash[:notice] = t :some_message) and then try to use this session in another Rails App without installed Globalize2 you'll got and Error.
And second, instead of "my message" it will be stored as "full_qualified_class_name, version, bla-bla my message". And this is also problem because session size is limited.
it will:
Comments
are You really sure this is a Globalize bug ?
this is how Globalize works and if it's decided to translate strings that way it's perfectly fine (You have some translation info with the string - like if it's a fallback translation, the locale used etc).what are Your suggestions, use String and forgot about all the added value of Static ?
without any suggestions I guess it won't get accepted, as the 2 rails app over the same session reason seems pretty non-standart ...If Your using a t helper method why don't U get rid of Static there if You don't need it and it stands in Your way :
def t t = I18n.t ... t.respond_to?(:original) ? t.original : t end
alexeypetrushin
Wed Oct 28 11:46:06 -0700 2009
| link
Probably You are right.
I'm not insist it's a bug, just pointed it out, in my case it results in broken session.It's not obvious, that translated strings will not be marshaled properly. Maybe it make sense to explicitly warn about it in readme.
-
Chained Backend doesn't provide reload! method
0 comments Created about 1 month ago by kuba97531Chained backend cannot be used in development environment in Rails 2.3.4
config.cache_classes = false I18n.backend = Globalize::Backend::Chain.new(Globalize::Backend::Static.new)results in:
#<NoMethodError: undefined method `reload!' for #<Globalize::Backend::Chain:0xb6935bf0>> (...)/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.1.3/lib/i18n.rb:80:in `reload!'Comments
-
model.clone() not working as exprected on translated columns
0 comments Created 23 days ago by cjkOn Rails 2.3.4, given I have a record_title-model:
% script/console test
r = RecordTitle.first
RecordTitle id: 10000, infotype: "SI", docno: "0258", unitno: "38", text: "Vel voluptate aliquid et doloribus sint eum ad sequ...", fun_group_id: 10000, fun_subgroup_id: 10000, created_at: "2001-11-14 23:00:00", updated_at: "2008-05-23 22:00:00", state: "draft"
rc = r.clone
RecordTitle id: nil, infotype: "SI", docno: "0258", unitno: "38", text: "Vel voluptate aliquid et doloribus sint eum ad sequ...", fun_group_id: 10000, fun_subgroup_id: 10000, created_at: "2001-11-14 23:00:00", updated_at: "2008-05-23 22:00:00", state: "draft"
rc.text
nil
r.text
"Vel voluptate aliquid et doloribus sint eum ad sequi."Even after saving the newly cloned model, the text remains empty. Thus it is not cloned as all the other atributes.
Comments
-
Translated models - validation works only for current locale
0 comments Created 15 days ago by kuba97531validations only work for the current locale, but I think it should work for all locales
in model
translates :description
validates_length_of :description, :maximum=>6, :allow_nil => trueusecase
I18n.locale = 'de'
record.description = "this string is too long for this field"
record.save # fails
I18n.locale = 'en'
record.save # doesn't fail, but should!Comments
-
the following gave me some problems :
article = Article.find(1) article.title ==> Globalize::Translation::Attribute article.update_attributes(params[:acticle]) article.title ==> StringProblems for view after update.
Comments
-
Attributes that are stored in an object_translations table, are not getting put into the rendered xml when you:
render :xml => @object
Comments












This worked for me - is this going to make it into the plugin?
I ran into the same problem recently, and it seems the fix wasn't incorporated yet. applied the patch on my fork and sent a pull request
okay - i will look at it and some other issues right away - lets see