[2.1] Adding simple Zend/I18n/Loader/Tmx #1992

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
5 participants
@lrodziewicz

A simple version of loader plus tests. I choose SimpleXML because the solution implemented into version 1 seemed for me over-complicated and libxml is enabled by default. I'm not an xpatch expert so there may be a better way of implementing it.
I not sure if the loader should report any incompatibilities with the standard eg. missing tuid attribute or seg node so I skipped it for now.

@weierophinney

This comment has been minimized.

Show comment Hide comment
@weierophinney

weierophinney Jul 26, 2012

Member

Waiting to merge this until we have a separate branch for 2.1 development

Member

weierophinney commented Jul 26, 2012

Waiting to merge this until we have a separate branch for 2.1 development

@Freeaqingme

This comment has been minimized.

Show comment Hide comment
@Freeaqingme

Freeaqingme Jul 29, 2012

Member

@weierophinney perhaps this may be a good moment to do so?

Member

Freeaqingme commented Jul 29, 2012

@weierophinney perhaps this may be a good moment to do so?

@weierophinney

This comment has been minimized.

Show comment Hide comment
@weierophinney

weierophinney Jul 29, 2012

Member

New feature... I'd prefer to wait to 2.1, as we're in rc phase currently.

On Saturday, July 28, 2012, Dolf Schimmel wrote:

@weierophinney perhaps this may be a good moment to do so?


Reply to this email directly or view it on GitHub:
zendframework#1992 (comment)

Matthew Weier O'Phinney
matthew@weierophinney.net
http://mwop.net/

Member

weierophinney commented Jul 29, 2012

New feature... I'd prefer to wait to 2.1, as we're in rc phase currently.

On Saturday, July 28, 2012, Dolf Schimmel wrote:

@weierophinney perhaps this may be a good moment to do so?


Reply to this email directly or view it on GitHub:
zendframework#1992 (comment)

Matthew Weier O'Phinney
matthew@weierophinney.net
http://mwop.net/

@Maks3w

This comment has been minimized.

Show comment Hide comment
@Maks3w

Maks3w Jul 29, 2012

Member

I added [2.1] preffix to the PR title

Member

Maks3w commented Jul 29, 2012

I added [2.1] preffix to the PR title

@Maks3w

This comment has been minimized.

Show comment Hide comment
@Maks3w

Maks3w Aug 6, 2012

Member

Hi,

We have renamed the folder for tests from Zend to ZendTest.

Can you rebase your PR to catch this change?

Thanks in advance.

Member

Maks3w commented Aug 6, 2012

Hi,

We have renamed the folder for tests from Zend to ZendTest.

Can you rebase your PR to catch this change?

Thanks in advance.

+
+ foreach($result as $node) {
+ $attributes = $node->attributes();
+ // Silently skip the nodes that does not have the 'tuid' attribute

This comment has been minimized.

Show comment Hide comment
@DASPRiD

DASPRiD Aug 20, 2012

Member

I wouldn't skip it silently, that can result in awkward error searching.

@DASPRiD

DASPRiD Aug 20, 2012

Member

I wouldn't skip it silently, that can result in awkward error searching.

This comment has been minimized.

Show comment Hide comment
@lrodziewicz

lrodziewicz Aug 21, 2012

At time when I wrote this I didn't see any sensible format validation in other loaders. Any suggestion how to handle it? Just an exception? I think additional data that is not translation is not a problem so we are OK to skip it. I probably should check tmx specification for that one.

@lrodziewicz

lrodziewicz Aug 21, 2012

At time when I wrote this I didn't see any sensible format validation in other loaders. Any suggestion how to handle it? Just an exception? I think additional data that is not translation is not a problem so we are OK to skip it. I probably should check tmx specification for that one.

This comment has been minimized.

Show comment Hide comment
@weierophinney

weierophinney Sep 14, 2012

Member

I agree with @LukaszR here -- if the only bit that you're interested in are nodes with a specific attribute, skip them. Yes, it can potentially lead to hard-to-locate errors, but if you're mixing information in the file, you have to expect that.

@weierophinney

weierophinney Sep 14, 2012

Member

I agree with @LukaszR here -- if the only bit that you're interested in are nodes with a specific attribute, skip them. Yes, it can potentially lead to hard-to-locate errors, but if you're mixing information in the file, you have to expect that.

+ $attributes = $node->attributes();
+ // Silently skip the nodes that does not have the 'tuid' attribute
+ if(isset($attributes['tuid'])) {
+ $textDomain[(string) $attributes['tuid']] = (string) $node->tuv->seg;

This comment has been minimized.

Show comment Hide comment
@DASPRiD

DASPRiD Aug 20, 2012

Member

You should test for the existence of $node->tuv->seg.

@DASPRiD

DASPRiD Aug 20, 2012

Member

You should test for the existence of $node->tuv->seg.

+ foreach($result as $node) {
+ $attributes = $node->attributes();
+ // Silently skip the nodes that does not have the 'tuid' attribute
+ if(isset($attributes['tuid'])) {

This comment has been minimized.

Show comment Hide comment
@DASPRiD

DASPRiD Aug 20, 2012

Member
  • Space missing after "if"
  • Why not test for isset($node['tuid']) ?
@DASPRiD

DASPRiD Aug 20, 2012

Member
  • Space missing after "if"
  • Why not test for isset($node['tuid']) ?
+
+ $xml = simplexml_load_file($filename);
+
+ if(!$xml) {

This comment has been minimized.

Show comment Hide comment
@DASPRiD

DASPRiD Aug 20, 2012

Member

Space missing after "if".

@DASPRiD

DASPRiD Aug 20, 2012

Member

Space missing after "if".

+
+ $textDomain = new TextDomain();
+
+ libxml_use_internal_errors(true);

This comment has been minimized.

Show comment Hide comment
@DASPRiD

DASPRiD Aug 20, 2012

Member

This won't work properly, and will likely raise notices with invalid XML files. Also you don't reset it to the original value afterwards.

@DASPRiD

DASPRiD Aug 20, 2012

Member

This won't work properly, and will likely raise notices with invalid XML files. Also you don't reset it to the original value afterwards.

This comment has been minimized.

Show comment Hide comment
@lrodziewicz

lrodziewicz Aug 21, 2012

Why so? I have tested it and it does not rise notice. Agree with the reset to the original value.

@lrodziewicz

lrodziewicz Aug 21, 2012

Why so? I have tested it and it does not rise notice. Agree with the reset to the original value.

@@ -0,0 +1,30 @@

This comment has been minimized.

Show comment Hide comment
@DASPRiD

DASPRiD Aug 20, 2012

Member

Aren't we generally using dashes (-) as space equivalent in file names in ZF?

@DASPRiD

DASPRiD Aug 20, 2012

Member

Aren't we generally using dashes (-) as space equivalent in file names in ZF?

This comment has been minimized.

Show comment Hide comment
@lrodziewicz

lrodziewicz Aug 21, 2012

Well, I did based on the existing files I have found in a /_files/ directory. Should I apply this change to all of them?

@lrodziewicz

lrodziewicz Aug 21, 2012

Well, I did based on the existing files I have found in a /_files/ directory. Should I apply this change to all of them?

This comment has been minimized.

Show comment Hide comment
@DASPRiD

DASPRiD Sep 3, 2012

Member

Can't hurt, sure.

@DASPRiD

DASPRiD Sep 3, 2012

Member

Can't hurt, sure.

+
+ public function testLoaderFailsToLoadMissingFile()
+ {
+ $loader = new TmxLoader();

This comment has been minimized.

Show comment Hide comment
@DASPRiD

DASPRiD Aug 20, 2012

Member

I'd suggest to instantiate the loader within the setUp method and store it in $this->loader, as it never takes constructor arguments.

@DASPRiD

DASPRiD Aug 20, 2012

Member

I'd suggest to instantiate the loader within the setUp method and store it in $this->loader, as it never takes constructor arguments.

This comment has been minimized.

Show comment Hide comment
@lrodziewicz

lrodziewicz Aug 21, 2012

First I tried to keep it consistent with the other tests that are initialized in this way.

Isn't that more convenient to start each test with a clean instance? If we wish to do it your way, then there should be also a test that check if loading a new file set up all internals properly.

@lrodziewicz

lrodziewicz Aug 21, 2012

First I tried to keep it consistent with the other tests that are initialized in this way.

Isn't that more convenient to start each test with a clean instance? If we wish to do it your way, then there should be also a test that check if loading a new file set up all internals properly.

This comment has been minimized.

Show comment Hide comment
@DASPRiD

DASPRiD Sep 3, 2012

Member

The class is freshly instantiated after each test, thus it is always clean.

@DASPRiD

DASPRiD Sep 3, 2012

Member

The class is freshly instantiated after each test, thus it is always clean.

@lrodziewicz

This comment has been minimized.

Show comment Hide comment
@lrodziewicz

lrodziewicz Aug 21, 2012

@Maks3w I will try to find time for this, this evening.

@Maks3w I will try to find time for this, this evening.

@ghost ghost assigned DASPRiD Sep 14, 2012

@weierophinney weierophinney reopened this Sep 14, 2012

@DASPRiD

This comment has been minimized.

Show comment Hide comment
@DASPRiD

DASPRiD Sep 28, 2012

Member

Closing as there was no activity for over a month.

Member

DASPRiD commented Sep 28, 2012

Closing as there was no activity for over a month.

@DASPRiD DASPRiD closed this Sep 28, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment