In previous versions, one could use $translation->addReference() to store arbitrary key-value payload in Translation objects. Since the $line parameter wasn't typehinted, one could use arbitrary string keys, turning the references into a key-value store.
In more current versions, to which I am trying to upgrade, the API is $translation->getReferences()->add(), and the ->add() method requires that the $line parameter be an int. Code that used references as payload store can no longer work.
What is the recommended way to store arbitrary key-value payload in Translation objects now?
If I have a .po file with non-string lines in references, created by previous version of my code, will the current version of this library be able to load these?
The references object is to store the different places where the translation is used. It's not meant to store arbitrary data. You can use headers for that.
In previous versions, one could use
$translation->addReference()
to store arbitrary key-value payload in Translation objects. Since the$line
parameter wasn't typehinted, one could use arbitrary string keys, turning the references into a key-value store.In more current versions, to which I am trying to upgrade, the API is
$translation->getReferences()->add()
, and the->add()
method requires that the$line
parameter be an int. Code that used references as payload store can no longer work.What is the recommended way to store arbitrary key-value payload in Translation objects now?
If I have a .po file with non-string lines in references, created by previous version of my code, will the current version of this library be able to load these?