Support for arrays in PHP filter
Original issue 203 created by @ysavourel on 2012-01-24T12:44:30.000Z:
Currently the PHP filter does not know how to make the difference between key and value in arrays: array("key" => "value");
See also http://tech.groups.yahoo.com/group/okapitools/message/2601
Comments (12)
-
Account Deleted -
Account Deleted Comment 2. originally posted by @ysavourel on 2012-12-20T00:00:36.000Z:
-
Note that in newer versions of PHP, the syntax looks like
$array = [ "foo" => "bar", "bar" => "foo", ];
However this older syntax is still supported by the language:
$array = array( "foo" => "bar", "bar" => "foo", );
-
Also, arrays can be nestable:
$array = [ "foo" => "bar", "baz" => [ 'A' => "Value A", 'B' => "Value B", ], ]
-
I think the correct behavior here is just to expose the values, so in that last example, the translation set would be "bar", "Value A", "Value B".
-
I was wondering, should we also support all variations of "array" structure? Hence, the code snippet below is supposed to be a valid one (please, pay attention to quotes):
$array = [ 'foo', "bar", $varKey => "bar", [ 'A' => "Value A", "B" => 'Value B', ], 'foo' => array( 'C' => "Value C", "D" => 'Value D', ), ];
So, the translation set would be "foo", "bar", "bar" (again), "Value A", "Value B", "Value C", "Value D".
-
If it's not too hard, that does look like the best behavior.
-
So far, two different approaches have been investigated. The first is to extend the current processing logic of the PHP content filter. The second is to re-implement the filter with the help of Jericho and JavaCC and should be considered as the best one to follow (for additional information please refer to the topic in the okapi-devel group).
So, the main concept of the second approach is to use Jericho to parse out the full tags (HTML + PHP), and then pull out the wanted stuff from the PHP tags with the help of a generated PHP parser by the JavaCC.
The current state of clarified requirements on the matter could be found attached in the "Re PHP filter re-implementation requirements.eml" file. The plan of development could be found attached in the "The plan of development with estimates.eml" file.
-
- attached Re PHP filter re-implementation requirements.eml
- attached The plan of development with estimates.eml
-
- edited description
- removed responsible
-
- changed status to on hold
Archive until we get another request
-
- changed version to M38
- Log in to comment
Comment [1.](https://code.google.com/p/okapi/issues/detail?id=203#c1) originally posted by @ysavourel on 2012-03-02T14:46:32.000Z:
This notation is used a lot in PHP string tables. (See http://tech.groups.yahoo.com/group/OmegaT/message/24582) It needs to be implemented sooner than later.