I'm slightly confused. You shouldn't store the complete string in the field, just the num_of_days. Let php build the phrase once a language has been chosen by the user.
e.g.
if($lang == 'en'){
echo ".en." . $num_of_days . ".en.";
}else{
echo ".cy." . $num_of_days . ".cy.";
}
I wouldn't do this for every instance of language string though. Using string arrays in a language file would be a better option.
diafol
Keep Smiling
10,634 posts since Oct 2006
Reputation Points: 1,628
Solved Threads: 1,506
Skill Endorsements: 57
Regardless, I'm not sure if this is the best way to store language strings. You're mixing the value (say '5') with the associated language string. THis may make the string unwieldy and difficult to update.
For each product, in the products table, I'd have the value in its own field, e.g. 'available_in' storing just integers
If you're storing language strings in the ps_product_lang table, it would benefit from have a generic statement that could be used for all products using a placeholder, e.g.
translations
translated_id (int/PK)
langstring_id (int/FK)
lang_id (tinyint/FK)
content (varchar or text)
1
5
4
Bydd y cynnyrch hwn ar gael ymhen %d diwrnod.
This would be related to a couple of tables:
langstrings
langstring_id (int/PK)
linkcode (varchar[30])
original (varchar or text)
5
PRODUCT_AVAILABLE_IN
This will be available in %d days.
langs
lang_id (tinyint/PK)
lang_code (varchar [10])
lang_encoding (varchar [10])
default_lang_name (varchar [15])
native_lang_name (varchar [15])
4
cy_gb
utf8
Welsh
Cymraeg
Using sprintf(), you can substitute the placeholder for a real value. This can be done easily enough with a join query and some php formatting.
I apologise if I went off track and didn't actually anser your question or if I misunderstood what you're trying to do. It's just that your data structure looks awkward. Feel free to ignore this post.
diafol
Keep Smiling
10,634 posts since Oct 2006
Reputation Points: 1,628
Solved Threads: 1,506
Skill Endorsements: 57
Question Answered as of 4 Months Ago by
diafol