Miles,

It is not a suggestion it is the correct way the code should be used.

As I stated in the previous email the pot file is reopened, using poedit for
example, and you merge the changes from your code. Your .po and .mo files
will have the correct msgid and your translators will be able to open the
file and "know" that it has been altered because the fields are marked as
fuzzy translation.

When I originally wrote this code I used gettext, which is a commonly used
implementation, as a model to build it for CakePHP.

http://en.wikipedia.org/wiki/GNU_gettext
http://www.gnu.org/software/gettext/
http://gnuwin32.sourceforge.net/packages/gettext.htm

There are many other examples you can find on the internet showing proper
way to use gettext.

Look at the site setup for translating GNU and other projects:
http://translationproject.org/

I doubt you will find a project out of the 160+ on that site using slugs
like you suggest.

You can use the code however you like though.

-- 
/**
* @author Larry E. Masters
* @var string $userName
* @param string $realName
* @returns string aka PhpNut
* @access  public
*/

On Wed, Oct 14, 2009 at 11:21 AM, Miles J <mileswjohn...@gmail.com> wrote:

>
> Additionally on the subject of PhpNut's suggestion. What if we change
> the text string in the view (english one) and then the translated ones
> wont match anymore because the msgid has changed. And if we generate
> new po files then we would have to translate them all over again.
> Thats primarily my reason for using slugs.
>
> On Oct 14, 7:15 am, Toby Ashley <lowpi...@gmail.com> wrote:
> > While this discussion is going on, I thought I'd raise / ask something...
> >
> > In a recent project, I needed to make it easy for administrators to be
> able
> > to edit the text used throughout the site. The site itself runs in 12
> > languages, and as a result I have 12 *.po files, one per territory. The
> > administrators for each language are fairly non-technical, and so the
> system
> > needed to be easy.
> >
> > I built a simple system which would do the following:
> >
> > -- Provide a 'download existing website text' button to the administrator
> -
> > the controller action would then read through the appropriate *.po file
> and
> > generate a CSV with two columns, the identifier (i'm also using
> descriptive
> > slugs, as mentioned by Miles) and the current string for that identifier
> >
> > -- The administrator can then make the necessary amendments before
> > re-importing the CSV. When re-importing, the system backs up the existing
> > *.po file and creates a new one, manually writing the msgid and msgstr
> > values from the data in the CSV. Finally, when this is done, the system
> > removes any relevant cache files and  hey presto - the website text is
> > updated.
> >
> > -- There's also tools to revert to previous backup, in case they make an
> > almighty mess of everything.
> >
> > This system worked fine for the project, and the administrators of the
> site
> > are maintaining the different languages with success, but I'm wondering
> if
> > there's a better / simpler / more recommend way of achieving the same
> > functionality. I guess it's kind of like a friendly, web-based interface
> for
> > editing these *.po files
> >
> > Any suggestions?
> >
> > Cheers,
> > toby
> >
> > On Wed, Oct 14, 2009 at 2:05 AM, Larry E. Masters aka PhpNut <
> >
> > php...@gmail.com> wrote:
> > > Cool, let me know if you have any questions.
> > > --
> > > /**
> > > * @author Larry E. Masters
> > > * @var string $userName
> > > * @param string $realName
> > > * @returns string aka PhpNut
> > > * @access  public
> > > */
> >
> > > On Tue, Oct 13, 2009 at 7:46 PM, Miles J <mileswjohn...@gmail.com>
> wrote:
> >
> > >> Well see now a lot of it makes sense. The guide is pretty vague on
> > >> i18n/l10n and how it works / is used.
> >
> > >> Will give this a try.
> >
> > >> On Oct 13, 5:39 pm, "Larry E. Masters aka PhpNut" <php...@gmail.com>
> > >> wrote:
> > >> > Incorrect, the file that is created using the i18n extract creates a
> > >> .pot
> > >> > file which is a template file and can be opened in any po editor or
> text
> > >> > editor. The template is not language specific. There is no reason to
> > >> create
> > >> > these files by hand. Write your code and output using the sentences
> you
> > >> > would normally use just wrap the string in __() function. Run the
> > >> extractor
> > >> > and you are done.
> > >> > Easiest tool to edit translations I have recently found is
> > >> poedit.www.poedit.net
> >
> > >> > I uploaded current core extracted pot file.
> >
> > >> >http://cake-php.googlegroups.com/web/default.pot
> >
> > >> > Download it and open in poedit.
> >
> > >> > The nice thing about these pot file is you can create a new version
> with
> > >> > changes in your application, reopen the template in poedit, and it
> will
> > >> > merge changes highlighting the strings that have changed.
> >
> > >> > Not sure if you are aware how the other translation functions work
> in
> > >> the
> > >> > core, but when it comes to handling plurals in a sentence, your
> slugs
> > >> will
> > >> > become more confusing.
> >
> > >> > for($number = 0; $i < 100; $number++) {
> > >> > sprintf(__n('There is %d apple in the fruit bowl', 'There are %d
> apples
> > >> in
> > >> > the fruit bowl', $number), $number);
> >
> > >> > }
> >
> > >> > msgid "There is %d apple in the fruit bowl"
> > >> > msgid_plural "There are %d apples in the fruit bowl"
> > >> > msgstr[0] ""
> > >> > msgstr[1] ""
> > >> > msgstr[2] ""
> > >> > msgstr[3] ""
> > >> > msgstr[4] ""
> > >> > msgstr[5] ""
> > >> > msgstr[6] ""
> >
> > >> > There are 16 plural rules that range from 1 form of plural to 6
> forms of
> > >> > plural depending on the value of $number. It all depends and the
> > >> language
> > >> > the content is being translated to. The above example be based on
> the
> > >> header
> > >> > in the po file, which poedit allows you to set based on the language
> you
> > >> are
> > >> > using.
> >
> > >> > Only 1 form of plural.
> > >> > "Plural-Forms: nplurals=1; plural=0;\n"
> >
> > >> > 6 forms of plural.
> > >> > "Plural-Forms: nplurals=4; plural=n==1 ? 0 : n==2 ? 1 : n==0 ||
> (n>=3 &&
> > >> > n<=10) ? 2 : 3;\n"
> >
> > >> > 14 other forms or plural are available. These will be added to the
> > >> > translation site I had online for the project before. This will be
> > >> coming
> > >> > back online in the next few weeks. They will also be added to the
> book,
> > >> with
> > >> > corrections on the proper use of these functions soon. If you need
> the
> > >> > correct plural form before then, let me know and I can reply with
> it.
> >
> > >> > --
> > >> > /**
> > >> > * @author Larry E. Masters
> > >> > * @var string $userName
> > >> > * @param string $realName
> > >> > * @returns string aka PhpNut
> > >> > * @access  public
> > >> > */
> >
> > >> > On Tue, Oct 13, 2009 at 6:50 PM, Miles J <mileswjohn...@gmail.com>
> > >> wrote:
> >
> > >> > > But you would need to make the english po file anyways if you are
> > >> > > going to distribute it and have it translated.
> >
> > >> > > On Oct 13, 12:58 pm, "Larry E. Masters aka PhpNut" <
> php...@gmail.com>
> > >> > > wrote:
> > >> > > > So you are basically using these as "defines"?
> > >> > > > --
> > >> > > > /**
> > >> > > > * @author Larry E. Masters
> > >> > > > * @var string $userName
> > >> > > > * @param string $realName
> > >> > > > * @returns string aka PhpNut
> > >> > > > * @access  public
> > >> > > > */
> >
> > >> > > > On Tue, Oct 13, 2009 at 2:19 PM, euromark (munich) <
> >
> > >> > > > dereurom...@googlemail.com> wrote:
> >
> > >> > > > > i agree with miles
> >
> > >> > > > > they should be slugged, short and precise
> > >> > > > > and explained in both the english and foreign .po file
> >
> > >> > > > > like
> >
> > >> > > > > "regMessageSuccess"
> > >> > > > > and
> > >> > > > > "You have been successfully registered"
> > >> > > > > "Sie sind nun erfolgreich angemeldet"
> >
> > >> > > > > or
> > >> > > > > "valErrorRecordNameExists"
> > >> > > > > for
> > >> > > > > "A record with this name already exists"
> >
> > >> > > > > this way you can easily change the "original" language text
> (here:
> > >> > > > > english) without having to change all the x places in the
> script
> > >> as
> > >> > > > > well
> >
> > >> > > > > maybe it is now supposed to be
> > >> > > > > "You cannot have two records with the same name"
> >
> > >> > > > > but the short slugged term has still the same basic meaning
> and
> > >> > > > > therefore remains the same
> >
> > >> > > > > On 13 Okt., 18:12, Miles J <mileswjohn...@gmail.com> wrote:
> > >> > > > > > I am personal extremely against naming your ids the full
> > >> sentence,
> > >> > > > > > what purpose does that serve? Its longer in both the .po and
> > >> .ctp
> > >> > > file
> > >> > > > > > and its a lot easier to reference slugs. To each his own I
> > >> guess.
> >
> > >> > > > > > On Oct 13, 7:42 am, "Larry E. Masters aka PhpNut" <
> > >> php...@gmail.com>
> > >> > > > > > wrote:
> >
> > >> > > > > > > Another thing I forgot to mention. You should be using
> full
> > >> strings
> > >> > > you
> > >> > > > > want
> > >> > > > > > > translated for the msgid.Example:
> >
> > >> > > > > > > msgid "By registering on this web site you are..."
> >
> > >> > > > > > > This is the way the core was designed to handle
> translations.
> > >> You
> > >> > > will
> > >> > > > > also
> > >> > > > > > > find it much easier for people to translate your
> application
> > >> if
> > >> > > they
> > >> > > > > have
> > >> > > > > > > everything they need in the 1 .po file vs looking for the
> text
> > >> > > related
> > >> > > > > to a
> > >> > > > > > > place holder.
> >
> > >> > > > > > > --
> > >> > > > > > > /**
> > >> > > > > > > * @author Larry E. Masters
> > >> > > > > > > * @var string $userName
> > >> > > > > > > * @param string $realName
> > >> > > > > > > * @returns string aka PhpNut
> > >> > > > > > > * @access  public
> > >> > > > > > > */
> >
> > >> > > > > > > On Tue, Oct 13, 2009 at 9:13 AM, Rob <rob...@catchit.pl>
> > >> wrote:
> >
> > >> > > > > > > > Any1 thought about creating little snippet which could
> speed
> > >> up
> > >> > > > > > > > hardcoded localization process.
> > >> > > > > > > > Here is the simple scenerio:
> > >> > > > > > > > 1) find strings within __('...') __('...',true) string
> > >> patterns
> > >> > > in /
> > >> > > > > > > > app folder
> > >> > > > > > > > 2) build arrays from default locale *.po files
> containing
> > >> locale
> > >> > > keys
> > >> > > > > > > > 3) append to end of these files missing id keys in form:
> > >> > > > > > > > msgid "_register_disclaimer"
> > >> > > > > > > > msgstr "TOODOO"
> >
> > >> > > > > > > > i create many multilang apps and i believe it could be
> major
> > >> > > speed
> > >> > > > > > > > boost for ppl like me.
> > >> > > > > > > > we dont need to update these files manually every time
> we
> > >> use
> > >> > > __().
> > >> > > > > we
> > >> > > > > > > > just run script when app is ready or changed and just
> update
> > >> > > TOODOO
> > >> > > > > > > > strings or send them to translators.
> >
> > >> > > > > > > > If some1 came up with idea how this could be easly done
> i
> > >> would
> > >> > > > > > > > apreciate this.
> >
> > >> > > > > > > > regular expressions? if so, how to build fault free one?
> >
>

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

Reply via email to