The Foxy forums are on the move!

We're in the process of moving our forums over to a new system, and so these forums are now read-only.
If you have a question about your store in the meantime, please don't hesitate to reach out to us via email.

Custom twig language variables

zlbzlb Member
I'm working on a custom checkout page and I was wondering if you have a recommended approach for setting up new language strings. I feel like there should be a way to do it with the custom values in the template configuration, but I'm not sure if there is a way to set one up to behave like the built in language strings.
Is that something that's possible?
  • brettbrett FoxyCart Team
    Hey @zlb. It would be nice to be able to set additional custom language strings, and that's something we've thought about in the past, but isn't current functionality.

    That said, we've done some custom language strings for a multi-lingual custom cart for one of our enterprise users in the past. Can you clarify a bit of what you're after? If it's not multi-lingual, you wouldn't need to bother with Twig; you could just hardcode. If it is multi-lingual, here's an example of what we have in the cart include template:
    {% set custom_lang = {'custom_change_the_country': 'Change the country', 'custom_available_courses': 'Available Courses',
    'custom_add_to_cart': 'Add to cart'} %}
    {% if language == "german" %}
    {% set custom_lang = {'custom_change_the_country': 'Land ändern', 'custom_available_courses': 'Verfügbare Kurse',
    'custom_add_to_cart': 'In den Warenkorb'} %}
    {% endif %}
    {% set custom_lang = config.lang|merge(custom_lang) %}
    {% set config = config|merge({"lang": custom_lang}) %}
    I'm not sure if that'll help, but let us know a little more about what you're trying to do and we can see if we can offer better advice.
  • zlbzlb Member
    Hi @brett,
    Yeah it is multi-language, I totally forgot to say that.
    Thank you for the example, that should work perfectly!
Sign In or Register to comment.