HTML Logo by World Wide Web Consortium (www.w3.org). Click to learn more about our commitment to accessibility and standards.

Moving forward with Composr

ocPortal has been relaunched as Composr CMS, which is now in beta. ocPortal 9 will be superseded by Composr 10.

Head over to compo.sr for our new site, and to our migration roadmap. Existing ocPortal member accounts have been mirrored.


Language files

Login / Search

 [ Join | More ]
 Add topic 
Posted
Rating:
#49255 (In Topic #10738)
Avatar

Community saint

Hi all

It's been a while since I last contributed here, so I won't even try to resist this one:

We have [descriptions] and [strings] in the .ini files.
What goes where?
Does it matter if a string migrates from one to the other?

Just to empty my bag of silly questions concerning language files…

Language files
I noticed that when an error message claims a language string is missing, the software is happy with me just adding the string in an ini file, not minding in which ini I put it (typically global.ini). Is this the case for all the strings? (IOW would OCP accept ALL the strings in just one big global.ini instead of 78 small files?).

LOCALE_SUBST=
How far can we go with this? How many replacement strings will it accept?
Is it always site-wide, or can it be restricted? Does it take jokers or spaces?
(For dates and times, D, l, S, F, M, are a bit of an issue when translating.
l (monday,…) and F (january,…) are easy, locale_subst can cope. jS (1st) I replace with d (01), and that's not a problem either.
D (mon,…) and M (jan,…are a bit trickier: If you add jan=jan,feb=fév, etc to locale_subst, you get some silly results when the full name is supposed to be shown.
Easy way out is to replace with l and F and let locale_subst do the job. This works fine but creates template problems due to extra width.)

Custom strings
In most other languages, words like first, latest, next… are gender sensitive.
Language strings containing these can create issues when used in different templates, addressing different things (image? file? Message?). Re-phrasing is not always possible.
Can new strings be created?
Ex. BLAH_BLAH=Show ten last ones
Is it possible to add BLAH_BLAH_F=xxx and BLAH_BLAH_M=zzz in the ini file, and change the BLAH_BLAH called in the templates to BLAH_BLAH_F or BLAH_BLAH_M according to what the thing is about?

calendar_minute=%I:%F %p
What will that display as? (looked everywhere for a clue on what this p will do, no luck)

All I can think of for now, but there will be a few more…  :$

 :thumbs:


 





www.precorp.fr

Last one to leave the country, please turn off the lights.
Back to the top
 
Posted
Rating:
#49262
Avatar

We have [descriptions] and [strings] in the .ini files.
What goes where?
Does it matter if a string migrates from one to the other?

Code

[descriptions]
EXAMPLE=I am here to describe what the string named EXAMPLE is for. Sometimes it is not obvious by the name, so we support the descriptions. You do not need to translate these - they are written to assist people translating.

[strings]
EXAMPLE=I am the example language string.

The order is important. 'descriptions' comes first. That way our language parser can be faster as it doesn't need to understand the sections it just reads it in as a list of pairs (string name, string value). i.e. EXAMPLE is read in twice, the second time overwriting the first one. High performance.

Is this the case for all the strings? (IOW would OCP accept ALL the strings in just one big global.ini instead of 78 small files?).

It always work to put it in global.ini. It wouldn't work to put it always in say iotds.ini because that's not always loaded up.

We split them into separate language files for two reasons:
  • modularity (e.g. iotds can be uninstalled)
  • performance. We don't want to have to load any more strings than necessary.

I would recommend following our scheme but it's not going to break things if you put them in global.ini if by mistake or in a hurry.

How far can we go with this? How many replacement strings will it accept?
Is it always site-wide, or can it be restricted? Does it take jokers or spaces?
(For dates and times, D, l, S, F, M, are a bit of an issue when translating.
l (monday,…) and F (january,…) are easy, locale_subst can cope. jS (1st) I replace with d (01), and that's not a problem either.
D (mon,…) and M (jan,…are a bit trickier: If you add jan=jan,feb=fév, etc to locale_subst, you get some silly results when the full name is supposed to be shown.
Easy way out is to replace with l and F and let locale_subst do the job. This works fine but creates template problems due to extra width.)

I'm not sure I understood all that, but LOCALE_SUBST is a bit of a fudge. It's designed as a fallback for when the operating systems locale tables (which are supposed to do all this date/time translation for you) fails. In theory you leave it entirely blank and just the 'locale' string to something correct (this can take a comma-separated list of values, as servers often have different sets of codenames for the locales they support). French should be widely supported - I actually added in LOCALE_SUBST as a response to Croatian not working correctly. It has no length restrictions.

Custom strings
In most other languages, words like first, latest, next… are gender sensitive.
Language strings containing these can create issues when used in different templates, addressing different things (image? file? Message?). Re-phrasing is not always possible.
Can new strings be created?
Ex. BLAH_BLAH=Show ten last ones
Is it possible to add BLAH_BLAH_F=xxx and BLAH_BLAH_M=zzz in the ini file, and change the BLAH_BLAH called in the templates to BLAH_BLAH_F or BLAH_BLAH_M according to what the thing is about?

Can you give an example where a current language string needs to be different for different genders? I can understand vaguely, but if you can show how a language string is used in two contexts and show me how you need those contexts to be (the translations you want) and thus why the language string needs to be split.

There are things you can do, but I'd rather not force translators to distribute their own templates - it could get messy. I'd rather see a list of problems and resolve them as bugs.

calendar_minute=%I:%F %p
What will that display as? (looked everywhere for a clue on what this p will do, no luck)

If you look at the PHP documentation for the 'strftime' function you can see they list all the meanings.

%I is hours in a 12-hour clock
%M is minutes
%p is AM or PM

I think you made '%F' up, it doesn't exist ;). You probably want %H:%M for 24-hour clock.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#49283
Avatar

Community saint

I think you made '%F' up, it doesn't exist ;). You probably want %H:%M for 24-hour clock.
Hmmm…
I understand what happened. In fact, you're right (again), I did make it up. But I was helped  :P
I saw the F here:

calendar.ini (4.1.8) said

[strings]
calendar_minute=%I:%M %p
calendar_minute_no_seconds=:00
calendar_minute_ampm_known=%I:%M
calendar_date=Y-m-d
calendar_date_verbose=l jS F Y
calendar_date_range_single=h:i (jS)
….
I was having a hard time displaying the dates, days and months in french in the calendar.
Started looking at the above, and the first place I could find the F was there:

Expand: fr.php.net/manual/en/function.date.php fr.php.net/manual/en/function.date.php

F was the month, in full and in english.
This is why started changing the strings to what I wanted, according to this table here, and then filled the locale_subst with the french equivalent of all the days and months.
Most amazing thing is, despite all this mess I made, I still have the calendar working on the site, in french…
This thing is idiot-proof - Tested and approved  :thumbs:

(I'll continue on the other topics in a more appropriate forum)

www.precorp.fr

Last one to leave the country, please turn off the lights.
Back to the top
 
Posted
Rating:
#49284
Avatar

Ah right, I see now.

If there are no '%' signs it's "date", if there are % signs it's "strftime". I'll make sure the documentation explains this.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
1 guests and 0 members have just viewed this: None
Control functions:

Quick reply   Contract

Your name:
Your message: