Hi,

Well.. Lets make a better example. There are two examples in this email
and sorry for the length.

*** Example 1 ***

Lets say there is a customizable form element giving possibility to
select on case by case basis define how many edit field are present. In
some other place on web page there is 2 field and on some other 3 fields.

Lets have an interval (DateInterval) example.

User is asked to input interval when some event occures again. This data
is defined in human understandable format (ISO 8601) so that if user
defines every month then it really is every month and does not start to
slide.

Now user is presented three different fields to define it: years, months
and days.

[years] [months] [days]

To make it look a bit prettier to user (and to cover all known use
cases) in example in English it could be:

"Event occurs every [years] years, [months] months and [days] days."

Then in some other page there could be:
"Event occurs every [weeks] weeks."

Now how to define this programmatically then. The current idea is to
construct it in blocks:

"{begin-message}{format[input1]}{in-between-delimeter}{format[input2]}{last-delimeter}{format[input2]}{end-message}"

In the first case one can defined:

array(
        "begin-message" => "Event occurs every ",
        "end-message" => ".",
        "in-between-delimeter" => ", ",
        "last-delimeter" => " and ",
        "format[input1]" => "{input} years",
        "format[input2]" => "{input} months",
        "format[input3]" => "{input} days"
        )

Now the localized version would be more like:

array(
        "begin message" => "ThisPlace.BeginMessageFormat",
        "end message" => "ThisPlace.EndMessageFormat",
...
)

Then in .po:

msgid "ThisPlace.BeginMessageFormat"
msgstr "Event occurs every "

msgid "ThisPlace.EndMessageFormat"
msgstr "."

With this mechanism one can create quite powerful tool.

Now lets say it has been decided that in some other locale it does not
need to be so verbose and user in that locale can easily guess what it
means or perhaps the just the writing style is just different.

Lets have example with less verbose to screen:

"[years] years, [months] months and [days] days."

Now if one wants to hide the begin part obivious idea is to just define
empty string for begin-message.

Other example might be:
"Event occurs every [years] years [months] months [days] days."

(delimeters went to empty strings)

When used with this kind of mechanism one cannot supply empty string
from localization file.

*** Example 2 ***

Another example could be that in some locale there is assumption that
some "add-up-clauses" are added because it has been custom for looong time.

Example, a hotel reservation page for non-smoking room:

Locale A: (it is custom that smoking is disallowed unless explicitly stated)

msgid "Reservation.NonSmokingNotice"
msgstr ""

Locale B: (it is custom that smoking is allowed everywhere)

msgid "Reservation.NonSmokingNotice"
msgstr "Please note that all our rooms are non-smoking rooms."

Now one could code that as following:

$nonSmokingNotice = __('Reservation.NonSmokingNotice', true);
if ($nonSmokingNotice != "")
{
        echo $html->tag('span', $nonSmokingNotice ...);
}

or simply:

__('Reservation.NonSmokingNotice');

***

>From my point of view, both of these cases are valid and currently hard
to make without creating hacks in the helpers to catch for empty string
tag or to modify cake libs.

Thanks,
Vesa Jääskeläinen

On 19.4.2010 5:48, Miles J wrote:
> If there is no msgstr, it outputs the msgid.
> 
> 1 - Not a bug.
> 
> 2 - Why do you need to get an empty string?
> 
> On Apr 18, 2:59 am, Vesa Jääskeläinen <[email protected]> wrote:
>> Hi All,
>>
>> In some situations some localization entries in .po file can have
>> empty strings defined in some languages and in some other languages
>> there should be some text.
>>
>> So in example in locale A's .po file there would be:
>>
>> msgid "Entry"
>> msgstr ""
>>
>> And then in locale B's .po file:
>>
>> msgid "Entry"
>> msgstr "This local has special stuff here"
>>
>> Now CakePHP seems to insist with __('Entry', true) giving "Entry" for
>> locale A instead of defined empty string.
>>
>> So the questions:
>>
>> 1) Can it be considered a bug that will be fixed in future release?
>> Preferably in which :)
>>
>> 2) If not, what is the way to get this empty string from localization
>> file in proper CakePHP way?
>>
>> I can always hack CakePHP's libs to work in this way but I would like
>> to keep it as close to original as possible.
>>
>> Thanks,
>> Vesa Jääskeläinen
>>
>> Check out the new CakePHP Questions sitehttp://cakeqs.organd help others 
>> with their CakePHP related questions.
>>
>> You received this message because you are subscribed to the Google Groups 
>> "CakePHP" group.
>> To post to this group, send email to [email protected]
>> To unsubscribe from this group, send email to
>> [email protected] For more options, visit this group 
>> athttp://groups.google.com/group/cake-php?hl=en
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected] For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en
> 

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to