Scan directories with Zend_Translate_Adapter

View: New views
8 Messages — Rating Filter:   Alert me  

Scan directories with Zend_Translate_Adapter

by Daniele Princiotta :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello Is there a possibility to scan a directory for language files with Zend_Translate_Adapter? I know it works when calling 'new Zend_Translate', with the 'scan' option, but if I want to add more language files from different directories later do I need to add them one by one with several addTranslation() calls? Thanks, Daniele

Re: Scan directories with Zend_Translate_Adapter

by thomasW :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Just use the same option with your Adapter at initiation.
Zend_Translate is only a wrapper.

Greetings
Thomas Weidner, I18N Team Leader
http://www.thomasweidner.com

----- Original Message -----
From: "Daniele Princiotta" <shadowdani@...>
To: <fw-i18n@...>
Sent: Saturday, February 02, 2008 10:47 AM
Subject: [fw-i18n] Scan directories with Zend_Translate_Adapter


>
> Hello
>
> Is there a possibility to scan a directory for language files with
> Zend_Translate_Adapter?
>
> I know it works when calling 'new Zend_Translate', with the 'scan' option,
> but if I want to add more language files from different directories later
> do
> I need to add them one by one with several addTranslation() calls?
>
> Thanks,
> Daniele
> --
> View this message in context:
> http://www.nabble.com/Scan-directories-with-Zend_Translate_Adapter-tp15241263s16154p15241263.html
> Sent from the Zend I18N/Locale mailing list archive at Nabble.com.
>


Re: Scan directories with Zend_Translate_Adapter

by Daniele Princiotta :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

But what if I already have a Zend_Translate instance and want to add new translations to this instance by scanning a directory? As far as I understand it, you add translations with $translate->addTranslation(), but this method requires a locale given to it, which in my case is not possible since a directory may contain different language files. Or is there perhaps another method which does this? Thanks, Daniele
Thomas Weidner-2 wrote:
Just use the same option with your Adapter at initiation. Zend_Translate is only a wrapper. Greetings Thomas Weidner, I18N Team Leader http://www.thomasweidner.com ----- Original Message ----- From: "Daniele Princiotta" To: Sent: Saturday, February 02, 2008 10:47 AM Subject: [fw-i18n] Scan directories with Zend_Translate_Adapter > > Hello > > Is there a possibility to scan a directory for language files with > Zend_Translate_Adapter? > > I know it works when calling 'new Zend_Translate', with the 'scan' option, > but if I want to add more language files from different directories later > do > I need to add them one by one with several addTranslation() calls? > > Thanks, > Daniele > -- > View this message in context: > http://www.nabble.com/Scan-directories-with-Zend_Translate_Adapter-tp15241263s16154p15241263.html > Sent from the Zend I18N/Locale mailing list archive at Nabble.com. >

Re: Scan directories with Zend_Translate_Adapter

by thomasW :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Directory Search is implemented in the constructor and calls addTranslation
with the right parameters on found translation files.
addTranslation must get a file and a locale to work properly.

But WHY do you want to add multiple translations afterwards ??
Do you have such a big application that you are working with more than 5000
sentences ?

Greetings
Thomas Weidner, I18N Team Leader
http://www.thomasweidner.com

----- Original Message -----
From: "Daniele Princiotta" <shadowdani@...>
To: <fw-i18n@...>
Sent: Saturday, February 02, 2008 11:23 AM
Subject: Re: [fw-i18n] Scan directories with Zend_Translate_Adapter


>
> But what if I already have a Zend_Translate instance and want to add new
> translations to this instance by scanning a directory?
>
> As far as I understand it, you add translations with
> $translate->addTranslation(), but this method requires a locale given to
> it,
> which in my case is not possible since a directory may contain different
> language files. Or is there perhaps another method which does this?
>
> Thanks,
> Daniele
>
>
> Thomas Weidner-2 wrote:
>>
>> Just use the same option with your Adapter at initiation.
>> Zend_Translate is only a wrapper.
>>
>> Greetings
>> Thomas Weidner, I18N Team Leader
>> http://www.thomasweidner.com
>>
>> ----- Original Message -----
>> From: "Daniele Princiotta"
>> To:
>> Sent: Saturday, February 02, 2008 10:47 AM
>> Subject: [fw-i18n] Scan directories with Zend_Translate_Adapter
>>
>>
>>>
>>> Hello
>>>
>>> Is there a possibility to scan a directory for language files with
>>> Zend_Translate_Adapter?
>>>
>>> I know it works when calling 'new Zend_Translate', with the 'scan'
>>> option,
>>> but if I want to add more language files from different directories
>>> later
>>> do
>>> I need to add them one by one with several addTranslation() calls?
>>>
>>> Thanks,
>>> Daniele
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Scan-directories-with-Zend_Translate_Adapter-tp15241263s16154p15241263.html
>>> Sent from the Zend I18N/Locale mailing list archive at Nabble.com.
>>>
>>
>>
>>
>
> --
> View this message in context:
> http://www.nabble.com/Scan-directories-with-Zend_Translate_Adapter-tp15241263s16154p15241506.html
> Sent from the Zend I18N/Locale mailing list archive at Nabble.com.
>


Re: Scan directories with Zend_Translate_Adapter

by Daniele Princiotta :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks for the answer.

It is not a size issue but rather a design one. My application requires each module to have its own language directory with the translation files, in order to easily add and remove modules.
So, the layout looks something like this:

/application
    - default
        - controllers
        - models
        - views
        - locale
    - othermodule
        ...

Hence I need to scan the locale directory for each module.

Is this something planned to be added, as I understand it is not implemented yet, or should I rather start creating it myself?

Thanks,
Daniele

Thomas Weidner-2 wrote:
Directory Search is implemented in the constructor and calls addTranslation
with the right parameters on found translation files.
addTranslation must get a file and a locale to work properly.

But WHY do you want to add multiple translations afterwards ??
Do you have such a big application that you are working with more than 5000
sentences ?

Greetings
Thomas Weidner, I18N Team Leader
http://www.thomasweidner.com

----- Original Message -----
From: "Daniele Princiotta" <shadowdani@gmail.com>
To: <fw-i18n@lists.zend.com>
Sent: Saturday, February 02, 2008 11:23 AM
Subject: Re: [fw-i18n] Scan directories with Zend_Translate_Adapter


>
> But what if I already have a Zend_Translate instance and want to add new
> translations to this instance by scanning a directory?
>
> As far as I understand it, you add translations with
> $translate->addTranslation(), but this method requires a locale given to
> it,
> which in my case is not possible since a directory may contain different
> language files. Or is there perhaps another method which does this?
>
> Thanks,
> Daniele
>
>
> Thomas Weidner-2 wrote:
>>
>> Just use the same option with your Adapter at initiation.
>> Zend_Translate is only a wrapper.
>>
>> Greetings
>> Thomas Weidner, I18N Team Leader
>> http://www.thomasweidner.com
>>
>> ----- Original Message -----
>> From: "Daniele Princiotta"
>> To:
>> Sent: Saturday, February 02, 2008 10:47 AM
>> Subject: [fw-i18n] Scan directories with Zend_Translate_Adapter
>>
>>
>>>
>>> Hello
>>>
>>> Is there a possibility to scan a directory for language files with
>>> Zend_Translate_Adapter?
>>>
>>> I know it works when calling 'new Zend_Translate', with the 'scan'
>>> option,
>>> but if I want to add more language files from different directories
>>> later
>>> do
>>> I need to add them one by one with several addTranslation() calls?
>>>
>>> Thanks,
>>> Daniele
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Scan-directories-with-Zend_Translate_Adapter-tp15241263s16154p15241263.html
>>> Sent from the Zend I18N/Locale mailing list archive at Nabble.com.
>>>
>>
>>
>>
>
> --
> View this message in context:
> http://www.nabble.com/Scan-directories-with-Zend_Translate_Adapter-tp15241263s16154p15241506.html
> Sent from the Zend I18N/Locale mailing list archive at Nabble.com.
>

Re: Scan directories with Zend_Translate_Adapter

by thomasW :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

You should have one translation file per module.
Having multiple files for one module brings other problems.

So all you have to do is adding the single file for the actual used model in
your bootstrap.

The standard way is to integrate all translation files and use a cache.
There are no problems as long as you dont have a massive amount on files
(>500) or sencences (>5000).

Greetings
Thomas Weidner, I18N Team Leader
http://www.thomasweidner.com

----- Original Message -----
From: "Daniele Princiotta" <shadowdani@...>
To: <fw-i18n@...>
Sent: Saturday, February 02, 2008 12:03 PM
Subject: Re: [fw-i18n] Scan directories with Zend_Translate_Adapter


>
> Thanks for the answer.
>
> It is not a size issue but rather a design one. My application requires
> each
> module to have its own language directory with the translation files, in
> order to easily add and remove modules.
> So, the layout looks something like this:
>
> /application
>    - default
>        - controllers
>        - models
>        - views
>        - locale
>    - othermodule
>        ...
>
> Hence I need to scan the locale directory for each module.
>
> Is this something planned to be added, as I understand it is not
> implemented
> yet, or should I rather start creating it myself?
>
> Thanks,
> Daniele
>
>
> Thomas Weidner-2 wrote:
>>
>> Directory Search is implemented in the constructor and calls
>> addTranslation
>> with the right parameters on found translation files.
>> addTranslation must get a file and a locale to work properly.
>>
>> But WHY do you want to add multiple translations afterwards ??
>> Do you have such a big application that you are working with more than
>> 5000
>> sentences ?
>>
>> Greetings
>> Thomas Weidner, I18N Team Leader
>> http://www.thomasweidner.com
>>
>> ----- Original Message -----
>> From: "Daniele Princiotta" <shadowdani@...>
>> To: <fw-i18n@...>
>> Sent: Saturday, February 02, 2008 11:23 AM
>> Subject: Re: [fw-i18n] Scan directories with Zend_Translate_Adapter
>>
>>
>>>
>>> But what if I already have a Zend_Translate instance and want to add new
>>> translations to this instance by scanning a directory?
>>>
>>> As far as I understand it, you add translations with
>>> $translate->addTranslation(), but this method requires a locale given to
>>> it,
>>> which in my case is not possible since a directory may contain different
>>> language files. Or is there perhaps another method which does this?
>>>
>>> Thanks,
>>> Daniele
>>>
>>>
>>> Thomas Weidner-2 wrote:
>>>>
>>>> Just use the same option with your Adapter at initiation.
>>>> Zend_Translate is only a wrapper.
>>>>
>>>> Greetings
>>>> Thomas Weidner, I18N Team Leader
>>>> http://www.thomasweidner.com
>>>>
>>>> ----- Original Message -----
>>>> From: "Daniele Princiotta"
>>>> To:
>>>> Sent: Saturday, February 02, 2008 10:47 AM
>>>> Subject: [fw-i18n] Scan directories with Zend_Translate_Adapter
>>>>
>>>>
>>>>>
>>>>> Hello
>>>>>
>>>>> Is there a possibility to scan a directory for language files with
>>>>> Zend_Translate_Adapter?
>>>>>
>>>>> I know it works when calling 'new Zend_Translate', with the 'scan'
>>>>> option,
>>>>> but if I want to add more language files from different directories
>>>>> later
>>>>> do
>>>>> I need to add them one by one with several addTranslation() calls?
>>>>>
>>>>> Thanks,
>>>>> Daniele
>>>>> --
>>>>> View this message in context:
>>>>> http://www.nabble.com/Scan-directories-with-Zend_Translate_Adapter-tp15241263s16154p15241263.html
>>>>> Sent from the Zend I18N/Locale mailing list archive at Nabble.com.
>>>>>
>>>>
>>>>
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Scan-directories-with-Zend_Translate_Adapter-tp15241263s16154p15241506.html
>>> Sent from the Zend I18N/Locale mailing list archive at Nabble.com.
>>>
>>
>>
>>
>
> --
> View this message in context:
> http://www.nabble.com/Scan-directories-with-Zend_Translate_Adapter-tp15241263s16154p15241773.html
> Sent from the Zend I18N/Locale mailing list archive at Nabble.com.


Re: Scan directories with Zend_Translate_Adapter

by Daniele Princiotta :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks, but how do you mean "one translation file per module"? Should I include say the Italian and English translation in one file only? What is the drawback in not doing so (apart from more files to include and parse)? Right now I have them all in separate files, hence why I need a directory scan.

Thanks,
Daniele

Thomas Weidner-2 wrote:
You should have one translation file per module.
Having multiple files for one module brings other problems.

So all you have to do is adding the single file for the actual used model in
your bootstrap.

The standard way is to integrate all translation files and use a cache.
There are no problems as long as you dont have a massive amount on files
(>500) or sencences (>5000).

Greetings
Thomas Weidner, I18N Team Leader
http://www.thomasweidner.com

----- Original Message -----
From: "Daniele Princiotta" <shadowdani@gmail.com>
To: <fw-i18n@lists.zend.com>
Sent: Saturday, February 02, 2008 12:03 PM
Subject: Re: [fw-i18n] Scan directories with Zend_Translate_Adapter


>
> Thanks for the answer.
>
> It is not a size issue but rather a design one. My application requires
> each
> module to have its own language directory with the translation files, in
> order to easily add and remove modules.
> So, the layout looks something like this:
>
> /application
>    - default
>        - controllers
>        - models
>        - views
>        - locale
>    - othermodule
>        ...
>
> Hence I need to scan the locale directory for each module.
>
> Is this something planned to be added, as I understand it is not
> implemented
> yet, or should I rather start creating it myself?
>
> Thanks,
> Daniele
>
>
> Thomas Weidner-2 wrote:
>>
>> Directory Search is implemented in the constructor and calls
>> addTranslation
>> with the right parameters on found translation files.
>> addTranslation must get a file and a locale to work properly.
>>
>> But WHY do you want to add multiple translations afterwards ??
>> Do you have such a big application that you are working with more than
>> 5000
>> sentences ?
>>
>> Greetings
>> Thomas Weidner, I18N Team Leader
>> http://www.thomasweidner.com
>>
>> ----- Original Message -----
>> From: "Daniele Princiotta" <shadowdani@gmail.com>
>> To: <fw-i18n@lists.zend.com>
>> Sent: Saturday, February 02, 2008 11:23 AM
>> Subject: Re: [fw-i18n] Scan directories with Zend_Translate_Adapter
>>
>>
>>>
>>> But what if I already have a Zend_Translate instance and want to add new
>>> translations to this instance by scanning a directory?
>>>
>>> As far as I understand it, you add translations with
>>> $translate->addTranslation(), but this method requires a locale given to
>>> it,
>>> which in my case is not possible since a directory may contain different
>>> language files. Or is there perhaps another method which does this?
>>>
>>> Thanks,
>>> Daniele
>>>
>>>
>>> Thomas Weidner-2 wrote:
>>>>
>>>> Just use the same option with your Adapter at initiation.
>>>> Zend_Translate is only a wrapper.
>>>>
>>>> Greetings
>>>> Thomas Weidner, I18N Team Leader
>>>> http://www.thomasweidner.com
>>>>
>>>> ----- Original Message -----
>>>> From: "Daniele Princiotta"
>>>> To:
>>>> Sent: Saturday, February 02, 2008 10:47 AM
>>>> Subject: [fw-i18n] Scan directories with Zend_Translate_Adapter
>>>>
>>>>
>>>>>
>>>>> Hello
>>>>>
>>>>> Is there a possibility to scan a directory for language files with
>>>>> Zend_Translate_Adapter?
>>>>>
>>>>> I know it works when calling 'new Zend_Translate', with the 'scan'
>>>>> option,
>>>>> but if I want to add more language files from different directories
>>>>> later
>>>>> do
>>>>> I need to add them one by one with several addTranslation() calls?
>>>>>
>>>>> Thanks,
>>>>> Daniele
>>>>> --
>>>>> View this message in context:
>>>>> http://www.nabble.com/Scan-directories-with-Zend_Translate_Adapter-tp15241263s16154p15241263.html
>>>>> Sent from the Zend I18N/Locale mailing list archive at Nabble.com.
>>>>>
>>>>
>>>>
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Scan-directories-with-Zend_Translate_Adapter-tp15241263s16154p15241506.html
>>> Sent from the Zend I18N/Locale mailing list archive at Nabble.com.
>>>
>>
>>
>>
>
> --
> View this message in context:
> http://www.nabble.com/Scan-directories-with-Zend_Translate_Adapter-tp15241263s16154p15241773.html
> Sent from the Zend I18N/Locale mailing list archive at Nabble.com.

Re: Scan directories with Zend_Translate_Adapter

by thomasW :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

No...
You said you are working with multiple module. For each module you should
have only one translation file per language.
You will NEVER add all languages because you know which language your user
wants to have or requests.

So you will only have to add the language from your needed modules.

Example:
Your user want english...
You are working with the module "News"... so you only have to add the file
"en.xx" from the module "News". Nothing more, nothing less.

It's all available in ZF, but if you think you must use it in a way
translations should never be done, feel free to code I18N classes yourself.
;-)

Greetings
Thomas Weidner, I18N Team Leader
http://www.thomasweidner.com

----- Original Message -----
From: "Daniele Princiotta" <shadowdani@...>
To: <fw-i18n@...>
Sent: Saturday, February 02, 2008 1:30 PM
Subject: Re: [fw-i18n] Scan directories with Zend_Translate_Adapter


>
> Thanks, but how do you mean "one translation file per module"? Should I
> include say the Italian and English translation in one file only? What is
> the drawback in not doing so (apart from more files to include and parse)?
> Right now I have them all in separate files, hence why I need a directory
> scan.
>
> Thanks,
> Daniele
>
>
> Thomas Weidner-2 wrote:
>>
>> You should have one translation file per module.
>> Having multiple files for one module brings other problems.
>>
>> So all you have to do is adding the single file for the actual used model
>> in
>> your bootstrap.
>>
>> The standard way is to integrate all translation files and use a cache.
>> There are no problems as long as you dont have a massive amount on files
>> (>500) or sencences (>5000).
>>
>> Greetings
>> Thomas Weidner, I18N Team Leader
>> http://www.thomasweidner.com
>>
>> ----- Original Message -----
>> From: "Daniele Princiotta" <shadowdani@...>
>> To: <fw-i18n@...>
>> Sent: Saturday, February 02, 2008 12:03 PM
>> Subject: Re: [fw-i18n] Scan directories with Zend_Translate_Adapter
>>
>>
>>>
>>> Thanks for the answer.
>>>
>>> It is not a size issue but rather a design one. My application requires
>>> each
>>> module to have its own language directory with the translation files, in
>>> order to easily add and remove modules.
>>> So, the layout looks something like this:
>>>
>>> /application
>>>    - default
>>>        - controllers
>>>        - models
>>>        - views
>>>        - locale
>>>    - othermodule
>>>        ...
>>>
>>> Hence I need to scan the locale directory for each module.
>>>
>>> Is this something planned to be added, as I understand it is not
>>> implemented
>>> yet, or should I rather start creating it myself?
>>>
>>> Thanks,
>>> Daniele
>>>
>>>
>>> Thomas Weidner-2 wrote:
>>>>
>>>> Directory Search is implemented in the constructor and calls
>>>> addTranslation
>>>> with the right parameters on found translation files.
>>>> addTranslation must get a file and a locale to work properly.
>>>>
>>>> But WHY do you want to add multiple translations afterwards ??
>>>> Do you have such a big application that you are working with more than
>>>> 5000
>>>> sentences ?
>>>>
>>>> Greetings
>>>> Thomas Weidner, I18N Team Leader
>>>> http://www.thomasweidner.com
>>>>
>>>> ----- Original Message -----
>>>> From: "Daniele Princiotta" <shadowdani@...>
>>>> To: <fw-i18n@...>
>>>> Sent: Saturday, February 02, 2008 11:23 AM
>>>> Subject: Re: [fw-i18n] Scan directories with Zend_Translate_Adapter
>>>>
>>>>
>>>>>
>>>>> But what if I already have a Zend_Translate instance and want to add
>>>>> new
>>>>> translations to this instance by scanning a directory?
>>>>>
>>>>> As far as I understand it, you add translations with
>>>>> $translate->addTranslation(), but this method requires a locale given
>>>>> to
>>>>> it,
>>>>> which in my case is not possible since a directory may contain
>>>>> different
>>>>> language files. Or is there perhaps another method which does this?
>>>>>
>>>>> Thanks,
>>>>> Daniele
>>>>>
>>>>>
>>>>> Thomas Weidner-2 wrote:
>>>>>>
>>>>>> Just use the same option with your Adapter at initiation.
>>>>>> Zend_Translate is only a wrapper.
>>>>>>
>>>>>> Greetings
>>>>>> Thomas Weidner, I18N Team Leader
>>>>>> http://www.thomasweidner.com
>>>>>>
>>>>>> ----- Original Message -----
>>>>>> From: "Daniele Princiotta"
>>>>>> To:
>>>>>> Sent: Saturday, February 02, 2008 10:47 AM
>>>>>> Subject: [fw-i18n] Scan directories with Zend_Translate_Adapter
>>>>>>
>>>>>>
>>>>>>>
>>>>>>> Hello
>>>>>>>
>>>>>>> Is there a possibility to scan a directory for language files with
>>>>>>> Zend_Translate_Adapter?
>>>>>>>
>>>>>>> I know it works when calling 'new Zend_Translate', with the 'scan'
>>>>>>> option,
>>>>>>> but if I want to add more language files from different directories
>>>>>>> later
>>>>>>> do
>>>>>>> I need to add them one by one with several addTranslation() calls?
>>>>>>>
>>>>>>> Thanks,
>>>>>>> Daniele
>>>>>>> --
>>>>>>> View this message in context:
>>>>>>> http://www.nabble.com/Scan-directories-with-Zend_Translate_Adapter-tp15241263s16154p15241263.html
>>>>>>> Sent from the Zend I18N/Locale mailing list archive at Nabble.com.
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>> --
>>>>> View this message in context:
>>>>> http://www.nabble.com/Scan-directories-with-Zend_Translate_Adapter-tp15241263s16154p15241506.html
>>>>> Sent from the Zend I18N/Locale mailing list archive at Nabble.com.
>>>>>
>>>>
>>>>
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Scan-directories-with-Zend_Translate_Adapter-tp15241263s16154p15241773.html
>>> Sent from the Zend I18N/Locale mailing list archive at Nabble.com.
>>
>>
>>
>
> --
> View this message in context:
> http://www.nabble.com/Scan-directories-with-Zend_Translate_Adapter-tp15241263s16154p15242409.html
> Sent from the Zend I18N/Locale mailing list archive at Nabble.com.

LightInTheBox - Buy quality products at wholesale price