• Post Reply Bookmark Topic Watch Topic
  • New Topic

Resource Bundle best practices  RSS feed

 
Ranch Hand
Posts: 43
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This question is related to Resource Bundle and I am not sure if this question belongs to this thread. My apology for it.

Well the question is say I have a content which contain html tag also. Sample content:

"This is <strong>Foo </strong>.<br/> This is <strong> Bar</strong>"

Now, I can proceed in 3 ways:

way 1:

message = This is <strong>Foo </strong>.<br/> This is <strong> Bar</strong>

way 2:

message 1: This is
message 2: Foo
message 3: Bar

way 3:

message 1: This is <strong>Foo </strong>
message 2: This is <strong> Bar</strong>

Now, can any one help me which is the best way to go ahead and reason behind the way.

Note: I prefer way 3 as its according to context of the sentence. Way 2 would have been ideal way, but it seems to me that the context is broken.

 
Marshal
Posts: 4053
239
Clojure IntelliJ IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can understand why you don't like 'Option 2' because you're not defining the emphasis, but I do think that this is the right approach.

The problem with options 1 and 3 is that you are coupling your resource bundles to the implementation, which in this case is HTML. What if you now needed to put some other type of GUI on your application? What if you want to use those messages in a log file? Those "strong" and "br" tags in your message props don't make any sense any more.

Keep your messages (text) in the resource bundles where they belong, and keep your formatting in the HTML where it belongs.
 
Amar Saikia
Ranch Hand
Posts: 43
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Tim. I also support your logic.

However, I have been told in my previous company that the translators in some languages find it difficult to translate some sentences until the context of that particular sentence is known to them.

So, according to them, in some languages, the following *may be* translated in two different ways in same language.

way 2:

message 1: This is
message 2: Foo
message 3: Bar

way 3:

message 1: This is <strong>Foo </strong>
message 2: This is <strong> Bar</strong>

I am not sure about this though.

 
Tim Cooke
Marshal
Posts: 4053
239
Clojure IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What 'translators" are you talking about? Do you mean the browser scraping sort like Google Translate? If so then they will be looking at the final text presented on the browser so it makes no difference how that text is constructed behind the scenes.

Perhaps you mean something else? If so, what?
 
Amar Saikia
Ranch Hand
Posts: 43
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I did not mean Google Translator. It was manual translator. We used to send our properties files to some other company and they manually translated those files.
 
Tim Cooke
Marshal
Posts: 4053
239
Clojure IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yea I got what you mean now. To be honest I'm not entirely sure what the best approach would be for this. It's an interesting problem and I'm sure you're not the first to come up against it. Maybe some other, cleverer, person will help us out here.

Edit: I gave this post some flags to try and entice more input.
 
Saloon Keeper
Posts: 7993
143
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Words don't always translate neatly one-to-one. If you have one word that has extra information associated with it (such as emphasis) this may result in the extra information having to be applied to different parts of the sentence in the translation.

I would recommend storing entire sentences in your resource bundle, including the tags. I don't see a problem with this, since these tags convey meaning, not formatting.
you should probably not put tags like <br /> in there, they're not semantic.

Your views can then choose to render the tags however they want. A browser can show a <strong> element as bold, and a log file can simply ignore the tags.
 
Tim Cooke
Marshal
Posts: 4053
239
Clojure IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stephan's approach sounds reasonable enough to me. I had not considered that the emphasis may move when translated so it makes perfect sense to put the whole sentence in as a single message property.

Good advice Stephan, thanks.
 
Amar Saikia
Ranch Hand
Posts: 43
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Stephan. This looks reasonable to me as well. Thanks Tim for helping by giving more flags.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!