Relationship on locale pt-PT

43 views
Skip to first unread message

Edson

unread,
May 7, 2012, 3:32:59 PM5/7/12
to Hobo Users
Hi everybody,

I'm workin on an app locale pt-PT and when i create my relationship
between tables the values don't show up correctly:

i have table 1

has_many :table2

but the value that apear is just Value1, instead of appear the
information that corresponds to "Value1".

Is there somethin that i'm doing wrong.

I've tried on en app localization and it works fine.

Thank you in advance

Edson Teixeira

Edson

unread,
May 14, 2012, 11:36:13 AM5/14/12
to Hobo Users
Hi everybody,

Is there any post related to this that i can try?

I can not find i way to make this work.

Any kind of help will be helpful.

Thank you in advance.

Edson Teixeira

erbecke

unread,
May 14, 2012, 4:47:47 PM5/14/12
to Hobo Users
hm... do you have the same problem with every value ? or just with
one?

are you using hobo with rails 2.3 or 3.x?

check your .yml file, perhaps there is something bad.

and check out your file encondig. You should use UTF-8


eddie.

Edson

unread,
May 14, 2012, 11:40:09 PM5/14/12
to Hobo Users
hi eddie, first off all thank you for your reply.

i'm using rails 3.0.9 and hobo 1.3.0.

it happens with all the values for all my entire app, but for the user
model.

wich .yml you mean. in my application.rb i have config.encoding =
"utf-8".

thank you,

edson.

Edson

unread,
May 15, 2012, 12:40:57 AM5/15/12
to Hobo Users
ohh, i forgot

i'm using postgresql also.

thank you

edson

erbecke

unread,
May 15, 2012, 5:03:08 PM5/15/12
to Hobo Users
hmm... I'm still under Rails 2.3 / Hobo 1.0, and I never had this
problem.

But... I don't understand why it only happens with your pt-PT
language.

Do you have only one language? You said that you faven't that problem
in english.

Your app use a en-US yml file? or english is your default language
without using a YML file for it?

Have you tried to use another language option, for example es-SP at
least with a blank language file?

(in order to determine if the problem is your YML language file, your
default settings, or whatever)

Best regards,
Eddie.

Edson

unread,
May 15, 2012, 5:45:06 PM5/15/12
to Hobo Users
hi eddie,

I only this issue with pt-PT , but when i start a new app and
configure (hobo g setup_wizard) the language to en i don't have this
problem.

My question is: is there possible to have multiple languages? if yes,
how?

And if i have pt-PT and en-US at my config i'll solve my issue?

thank you,

edson

Ignacio Huerta

unread,
May 16, 2012, 3:35:42 PM5/16/12
to hobo...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Edson,

We are working with 1.3 we have several spanish only and some
spanish+english applications (for example http://www.islandiacar.com).
I suppose the problem lies with the translation file format.

Can you provide us with more detailed information about the error?
Some code or screenshots would be great. I would like to reproduce it
locally if I can.

On the other side, have you tried setting "
config.hobo.show_translation_keys = true" on application.rb and
restarting your application? It helps a lot to debug i18n problems.

Regards,
Ignacio

El 15/05/12 23:45, Edson escribi�:
- --
Ignacio Huerta Arteche
http://www.ihuerta.net
Tel�fono: 0034 645 70 77 35
Email realizado con software libre
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk+0AY4ACgkQBPlUJ6RHaOTruwCfbOrPFaZYa3HrYXR8jsoYzvlE
UJ4AniGlPdHxPHPCZsMBBNBNmBKHjOtl
=J49Y
-----END PGP SIGNATURE-----

erbecke

unread,
May 16, 2012, 4:25:19 PM5/16/12
to Hobo Users

I agree with Ignacio.

Please tell us how did you configure i18n in your application
controller and your site.

If you set a YML language file, then you may use as many languages as
you want, each language in a different file setting it with the
I18n.locale variable.

In my web-app, each user can choose which language they want to use
(current_user.language).


---- application_controller.rb
...


before_filter :set_locale

def set_locale
# update session if logged
if current_user.to_s != "guest"
session[:locale] = current_user.language.to_s
end

# read url locale param or default_locale for guest users
if current_user.to_s == "guest"
session[:locale] = params[:locale] #I18n.default_locale
end

# set locale based on session or default
I18n.locale = session[:locale] || I18n.default_locale

end

-----

best regards,

eddie.




On May 16, 4:35 pm, Ignacio Huerta <igna...@ihuerta.net> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi Edson,
>
> We are working with 1.3 we have several spanish only and some
> spanish+english applications (for examplehttp://www.islandiacar.com).
> I suppose the problem lies with the translation file format.
>
> Can you provide us with more detailed information about the error?
> Some code or screenshots would be great. I would like to reproduce it
> locally if I can.
>
> On the other side, have you tried setting "
> config.hobo.show_translation_keys = true" on application.rb and
> restarting your application? It helps a lot to debug i18n problems.
>
> Regards,
> Ignacio
>
> El 15/05/12 23:45, Edson escribi�:
> Tel�fono: 0034 645 70 77 35
> Email realizado con software libre
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (GNU/Linux)
> Comment: Using GnuPG with Mozilla -http://enigmail.mozdev.org/

Edson

unread,
May 17, 2012, 6:07:37 AM5/17/12
to hobo...@googlegroups.com
hi ignacio,

thank you for the reply.

i have a has_many/belongs_to relationship between my cadastro table and some others (like sexo).

but as you can see on the screenshot, when i create a new value for sexo table on the sexo index page i get the Sexo 1 value instead of "Masculino" that is the real value i've put on the table.

The same happens on the cadastro table when i try to select the sexo value "Masculino". It appears Sexo 1.

The cadastro code:
class Cadastro < ActiveRecord::Base

  hobo_model # Don't put anything above this

  fields do
    nome        :string
    alcunha     :string
    n_doc       :string, :unique
    local_nasc  :string
    dt_nasc     :date
    nome_conj   :string
    ndoc_conj   :string, :unique
    ender_resid :string
    tem_resid   :string
    tel_fixo    :integer, :unique
    tel_mvl     :integer, :unique
    tel_vizinho :integer, :unique
    nm_pai      :string
    nm_mae      :string
    refere      :string
    num_agrefam :integer
    num_filho   :integer
    timestamps
  end
belongs_to :est_civil
belongs_to :sexo
belongs_to :nacionalidade
belongs_to :bairro
belongs_to :cidade
belongs_to :ilha
belongs_to :tp_resid
belongs_to :escolaridade

the sexo code:
class Sexo < ActiveRecord::Base

  hobo_model # Don't put anything above this

  fields do
    sexo :string
    timestamps
  end
has_many :cadastros, :dependent => :destroy

i hope this help

thank you all



Em quarta-feira, 16 de maio de 2012 18h35min42s UTC-1, Ignacio Huerta escreveu:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Edson,

We are working with 1.3 we have several spanish only and some
spanish+english applications (for example http://www.islandiacar.com).
I suppose the problem lies with the translation file format.

Can you provide us with more detailed information about the error?
Some code or screenshots would be great. I would like to reproduce it
locally if I can.

On the other side, have you tried setting "
config.hobo.show_translation_keys = true" on application.rb and
restarting your application? It helps a lot to debug i18n problems.

Regards,
Ignacio

El 15/05/12 23:45, Edson escribi�:
Tel�fono: 0034 645 70 77 35
sexo_index.png
novo_cadastro.png

Edson

unread,
May 17, 2012, 6:08:57 AM5/17/12
to hobo...@googlegroups.com
hi eddie,
sexo_index.png
novo_cadastro.png

Edson

unread,
May 17, 2012, 1:06:02 PM5/17/12
to hobo...@googlegroups.com
i eddie,

i'll give it a try.

my last post i forgot to attach the prints for "  config.hobo.show_translation_keys = true".

well here it goes.

thank you.

edson
sexo_index1.png
novo_cadastro1.png

erbecke

unread,
May 17, 2012, 4:17:37 PM5/17/12
to Hobo Users
Edson, I think that your problem isn't i18n or translation.

Your problem is with the default name of the Model.

Try to add the name in your sexo.rb model: Hobo doesn't know which
field of the model you want to use as default name.

fields do
sexo :string, :name => "True"
timestamps
end


or you can add the following:

def name
self.sexo
end


best regards,
eddie.
>  sexo_index1.png
> 34KViewDownload
>
>  novo_cadastro1.png
> 98KViewDownload

Edson

unread,
May 17, 2012, 8:10:52 PM5/17/12
to hobo...@googlegroups.com
hi eddie,

YOU SOLVED MY PROBLEM.

Now it's working perfect!!!

Thank You Very Much.

Best Regards,

Edson.

Edson

unread,
May 17, 2012, 9:00:27 PM5/17/12
to hobo...@googlegroups.com
hi eddie,

it works but my app just changed de language to English.

what could that be?

best regards

edson

Tiago Franco

unread,
May 20, 2012, 9:19:38 AM5/20/12
to hobo...@googlegroups.com
Hi Edson,

I wonder why you're using Portuguese names for the columns instead of english names. "sexo" should be in fact "gender". I18n should take care of the translation for you, but the column names, table names, etc should be in EN.

Remember that rails will try to pluralize table names, etc, assuming they're in EN. You'll have huge problems if you use other language for code variables.

My suggestion is that:

1 - translate all code to EN
2 - extend the i18n file for the names you need to translate (i.e. cadastro should be profile, sexo should be gender, etc).

Hope it helps.
Reply all
Reply to author
Forward
0 new messages