Hi @ilyapokrov,
Question: What should be done and how to write the code, if you need to specify both the first and second codes?
It’d be easiest to just add a new translation rule in the array, e.g.:
'Male| Female' => 'for men|for women'
Or, if you’re translating before changing the comma:
'Male, Female' => 'for men|for women'
@wpallimport,
Did I understand you correctly?
For example, there are such parameters:
<param name = "Gender"> Female </param>
<param name = "Gender"> Male</param>
<param name = "Gender"> Female, Male </param>
<param name = "Gender"> Male, Female </param>
<param name = "Gender"> Male, Female, Child </param>
That is, I need to write and translate each value manually?
[my_map_data ({param [@name="Gender"]})]
function my_map_data ($ data) {
$ map = array (
'Male' => 'for men',
'Female' => 'for women',
'Female, Male' => 'for women|for men',
'Male, Female' => 'for women|for men',
'Male, Female, Child' => 'for women|for men|for children',
);
return (array_key_exists ($ data, $ map))? $ map [$ data]: $ data;
}
It happens that new parameter values appear. And if I have not specified them, then in the end I will get some kind of nonsense if I do not specify this parameter for translation.
Hey @ilyapokrov,
It happens that new parameter values appear. And if I have not specified them, then in the end I will get some kind of nonsense if I do not specify this parameter for translation.
In that case, it might be best to modify the “my_map_data” function so that it explode()‘s the gender values into an array, loops through each value and maps them individually, then implode()‘s the translated values and returns them to the import field.
@wpallimport,
I am very sorry, but I did not understand anything =)))
Can you show it with my example?
Hey @ilyapokrov,
I’m sorry, but I don’t have an example snippet for this.