NewPath-Consulting / ez-wildapricot-webdesigner

EZ Wild Apricot Web Designer modifies CSS and the DOM with a simple CSV configuration file. It can be used to modify hard coded strings in Wild Apricot and provide support for multi-lingual websites.
https://newpathconsulting.com/watm
GNU General Public License v3.0
4 stars 0 forks source link

Creating a WATM "tag" that can swap out text in user provided text #46

Closed asirota closed 3 months ago

asirota commented 2 years ago

It would be nice to have EZ Web Designer be able to toggle translations in the following areas:

An idea is to add a special "tag" that would rarely appear in any text that we could parse and swap like we do with .english and .french classes.

I propose a tag called [ezweb] that has a few options

[ezweb language="xx"] where xx is the official 2 letter ISO 639-1 language code

Example event name in 2 languages: [ezweb language="en"]English event name[/ezweb] [ezweb language="fr"]French event name[/ezweb]

Here's how a "description" could look in Event description

[ezweb language="en"]

Event HTML in English

[/ezweb]

[ezweb language="fr"]

Event HTML in French

[/ezweb]

[ezweb language="es"]

Event HTML in Spanish

[/ezweb]

This would eliminate the need to attach HTML classes to the code of the description.

mDisna commented 2 years ago

This is a good idea, however many or these use cases (events for example) use the title and body copy in the email macros, so all versions including the tags will be shown.

mDisna commented 6 months ago

rather than use the ISO language code, we should use the class name to keep things consistent.

would this be an add-on or part of the core plugin?

mDisna commented 4 months ago

Tag added as an add-on in fa490ae. Works only on event titles and descriptions.

Usage: Add [ez xxxx] ... [/ez] tags surrounding content of a certain language. Replace xxxx with the language class name set up in the JS settings.

Example: [ez english]English Text[/ez][ez french]French Text[/ez]

As with other add-ons, include ez-language in the JS config to use:

ez_addons = ["ez-language"];
mDisna commented 4 months ago

@asirota This is ready for review once the CORS issue has been resolved.

asirota commented 4 months ago

Can you add support for product titles and descriptions in the online store?

asirota commented 4 months ago

I noted that the maximum event title length is 80 characters, almost half of these would be used for the tags for 2 languages so you have 40 characters left for 2 event titles.

asirota commented 4 months ago

When I enter an event description like this

[ez english]May 1 2023 Tickets[/ez]

[ez french]Billets pour le 1er mai 2023[/ez]

It doesn't render either langauge.

Acually even if I enter it without the carriage returns it doesn't seem to work. Here's the example [ez english]May 1 2023 Tickets[/ez][ez french]Billets pour le 1er mai 2023[/ez]

https://newpathconsulting.wildapricot.org/admin/events/details/?DetailsDisplayMode=View&eventId=5270035&selTab=1

The content disappears and neither langauge shows.

mDisna commented 4 months ago

I can't access the test site to check the events, but if you are using the latest version, it should work.

I've updated the addon to work with breadcrumbs, event titles, and event descriptions. It seems that the event title may be cached for the shopping cart and may not update without refreshing the page.

asirota commented 4 months ago

I can't access the test site to check the events, but if you are using the latest version, it should work.

I've updated the addon to work with breadcrumbs, event titles, and event descriptions. It seems that the event title may be cached for the shopping cart and may not update without refreshing the page.

Ok i am using the latest add on version now -- see the event below -- the event description doesn't render

https://newpathconsulting.wildapricot.org/event-5780346

mDisna commented 4 months ago

what is the html in the event description?

asirota commented 4 months ago

Here's a test product -- note the product name disappears in French

https://newpathconsulting.wildapricot.org/Sys/Store/Products/332932

asirota commented 4 months ago

what is the html in the event description?

<p>[ez english]English Description[/ez]</p> <p>[ez french]French Description[/ez]</p>

asirota commented 4 months ago

On the confirmation page when checking out the online store the product name is not translated: https://newpathconsulting.wildapricot.org/Sys/Store/Checkout#step-3

image

asirota commented 4 months ago

It doesn't translate on the financial document (invoice) either:

https://newpathconsulting.wildapricot.org/Sys/FinDocument/95461420

image

mDisna commented 4 months ago

You have an error in your french.csv which is preventing the addon from running completely.

As mentioned previously, It seems that the event title may be cached for the shopping cart and may not update without refreshing the page.

asirota commented 4 months ago

You have an error in your french.csv which is preventing the addon from running completely.

As mentioned previously, It seems that the event title may be cached for the shopping cart and may not update without refreshing the page.

I fixed the error in french.csv and it still doesn't render the event description. The online store product name still doesn't render when I hard refreshed in French.

mDisna commented 4 months ago

The issue with the description is trying to account for all the ways the tags could be ordered without returning invalid html. I'll keep adjusting the regex.

As for the product listing name on the product page, this looks correct so I'm not sure what's happening. It works on my test site. (correction: not working in some places on my test site - will report back)

mDisna commented 4 months ago

@asirota This is ready for testing again. I've uploaded it to https://newpathconsulting.wildapricot.org

Step 3 of the checkout may not trigger change until you refresh that page, but outside of that the titles and descriptions for events and products should change, including on the event calendar.

asirota commented 3 months ago

implemented in 2.2 as ez-language add on