HTML tags in I18N XLIFF Dictionary file

This is for discussion, mainly on 1.x but there's some 2.x topics here too.

HTML tags in I18N XLIFF Dictionary file

Postby frikus » Wed Jan 09, 2008 10:58 pm

When I use html tags inside the <source> and <target> tags in the XLIFF Dictionary file , the text between them disappears in the page. Example:

Code: Select all
<trans-unit id="1">
  <source>Welcome to our <b>website</b>.</source>
  <target>Bienvenue sur notre <b>site web</b>.</target>
</trans-unit>


I'm getting only 'Welcome to our ' or 'Bienvenue sur notre ' in the resulting page.

'The Book' says:

Code: Select all
// Good way to enable text translation
<?php echo __('Welcome to all the <b>new</b> users') ?>


But it's not working for me.

What is the right way to do this?

Thanks.
frikus
Junior Member
 
Posts: 9
Joined: Wed Oct 31, 2007 2:08 am

Re: HTML tags in I18N XLIFF Dictionary file

Postby danieli » Thu Jan 10, 2008 2:34 am

Hi

Did you try to remove the <b></b> tags from the XLIFF dictionary?

Why don't you use <strong></strong> instead of <b>? The former is W3C-friendly
danieli
Member
 
Posts: 34
Joined: Thu Nov 08, 2007 7:59 pm
Location: Città del Capo

Re: HTML tags in I18N XLIFF Dictionary file

Postby frikus » Thu Jan 10, 2008 3:49 am

I didn't try to remove them because I want them to be there.

I just want to highlight one word in the phrase.

It could be <b> or <strong> or <em> or anything...

I used <b> tag just for example, because it's short.
frikus
Junior Member
 
Posts: 9
Joined: Wed Oct 31, 2007 2:08 am

Re: HTML tags in I18N XLIFF Dictionary file

Postby pachocho » Tue May 05, 2009 3:37 pm

I'm having the same problem, no matter what tag i use.

The example found in the book does not work.

I'm also having another huge problem with characters like à è ì ò ù. Is there a way to use them in dictionary files?

thanks
pachocho
Member
 
Posts: 87
Joined: Mon May 26, 2008 9:18 am
Location: Italy

Re: HTML tags in I18N XLIFF Dictionary file

Postby whalexis » Thu Oct 08, 2009 4:07 pm

pachocho wrote: I'm having the same problem, no matter what tag i use.

The example found in the book does not work.

I'm also having another huge problem with characters like à è ì ò ù. Is there a way to use them in dictionary files?

thanks


Replace the special char by their unicode XML value.
Like È equals '& #200;' (remove the space between & and #)
For a complete list of characters see here
whalexis
Faithful Member
 
Posts: 207
Joined: Wed Jul 16, 2008 7:14 pm

Re: HTML tags in I18N XLIFF Dictionary file

Postby whalexis » Thu Oct 08, 2009 4:12 pm

frikus wrote: I didn't try to remove them because I want them to be there.

I just want to highlight one word in the phrase.

It could be <b> or <strong> or <em> or anything...

I used <b> tag just for example, because it's short.


I don't know if you already get the solution.
I have one.
I you replace < and > by their XML unicode (see my previous post), it will work. I just tried it... and it's great
whalexis
Faithful Member
 
Posts: 207
Joined: Wed Jul 16, 2008 7:14 pm

Re: HTML tags in I18N XLIFF Dictionary file

Postby jjoaco » Tue May 18, 2010 10:04 pm

lib/symfony/i18n/sfMessageSource_XLIFF.class.php

Code: Select all
      $source = (string) $unit->source;
      $translations[$source][] = (string) $unit->target;


to

Code: Select all
      $source = (string) str_replace(array('<source>', '</source>'), '', $unit->source->asXML());;
      $translations[$source][] = (string) str_replace(array('<target>', '</target>'), '', $unit->target->asXML());
jjoaco
Junior Member
 
Posts: 6
Joined: Wed Aug 27, 2008 7:34 pm

Re: HTML tags in I18N XLIFF Dictionary file

Postby pedrocasado » Fri Jan 11, 2013 2:15 am

jjoaco wrote:lib/symfony/i18n/sfMessageSource_XLIFF.class.php

Code: Select all
      $source = (string) $unit->source;
      $translations[$source][] = (string) $unit->target;


to

Code: Select all
      $source = (string) str_replace(array('<source>', '</source>'), '', $unit->source->asXML());;
      $translations[$source][] = (string) str_replace(array('<target>', '</target>'), '', $unit->target->asXML());



Thanks! That worked!!
pedrocasado
Junior Member
 
Posts: 9
Joined: Sat Dec 11, 2010 12:18 am

Re: HTML tags in I18N XLIFF Dictionary file

Postby shayanjameel08 » Thu Oct 24, 2013 7:05 am

When deciding about internationalization the toughest part IMO is the choice of storage format.

For example the Zend PHP Framework offers the following adapters which cover pretty much all my options:

Array : no, hard to maintain
CSV : don't know, possible problems with encoding
Gettext : frequently used, poEdit for all platforms available BUT complicated
INI : don't know, possible problems with encoding
TBX : no clue
TMX : too much of a big thing? no editors freely available.
QT : not very widespread, no free tools
XLIFF : the comming standard? BUT no free tools available.
XMLTM : no, not what I need

basically I'm stuck with the 4 'bold' choices. I would like to use INI files but I'm reading about the encoding problems... is it really a problem, if I use strict UTF-8 (files, connections, db, etc.)?

I'm on Windows and I tried to figure out how poEdit functions but just didn't manage. No tutorials on the web either, is gettext still a choice or an endangered species anyways?

What about XLIFF, has anybody worked with it? Any tips on what tools to use?

Any ideas for Eclipse integration of any of these technologies?
shayanjameel08
Junior Member
 
Posts: 10
Joined: Mon Oct 21, 2013 7:19 am


Return to General discussion

Who is online

Users browsing this forum: Google [Bot] and 2 guests