MasaCMS/MasaTranslations

Translate plugin

Closed this issue · 16 comments

Discussed in MasaCMS/MasaCMS#94

Originally posted by brucebailey June 20, 2022
I will start with saying I have never used the translate plugin so this post could very well be me not setting it up properly.

  1. Created two sites, default (English) and test translate site (French).
  2. Install plugin on default site and assign to both sites with flags showing.
  3. Create home page content on both sites and assign content nodes of translated content on each home page.
  4. Put #m.dspObject(object='muratranslationstools')# in the nav
  5. Reload site

I do not see anything showing where step 4 is to change the language.
Also tried it directly in page content [m]m.dspObject(object='muratranslationstools')[/m] with nothing showing.

Found and tried this too (#m.dspObject(object="muratranslationsnavtools", objectparams={muratranslationstooltype='selectbox'})#) and get the following error:

500 Error
invalid component definition, can't find component [MuraTranslations.cfcs.translationManager]
Code:0
Type:expression

On this same topic, because I have never used this plugin before, is there a URL string I can append to make the other language appear?

For instance: www.mysite.com/?lan=fr

I am having the same issue where I do not see the flags or even text.

#m.dspObject(object='masatranslationstools')#
Above is the code that I am using.

I could hard code it but that defeats one of the purposes of having the plugin.
I have done a comparison to the old mura translation and masa and other than some minor CSS changes that I did on my old site and declarations that the translator is now MASA there isn't much difference.

When I inspect nothing even shows up at the place where the plugin is supposed to show.

What are we missing?

Thank you.

@brucebailey you could write some custom code that picks up the url param and triggers a change of site.

I hope the developer picks up on this because I can't transition one of our largest sites until this translation plugin works properly. I have tried every version that I can think of, but nothing is working. Can someone please fix the Translation Plugin for MASA.

For those that are still having issue with the translation plugin not working I think I finally have fixed the issue.

In this file: /plugins/MasaTranslations/display_objects/muratranslationsnavtools/index.cfm

Starting at line 13, the original code looks for the Mura folder. I changed the following to look in the MASA translation folder. Please note three items need to be replaced from Mura to Masa

pluginpath = m.globalConfig('context') & '/plugins/MasaTranslations'; pluginConfig = m.getPlugin('MasaTranslations'); translationManager = CreateObject('component', 'MasaTranslations.cfcs.translationManager').init(m.globalConfig(),pluginConfig);

Also, the code to display should be

#m.dspObject(object='muratranslationsnavtools')#

This seems to have fixed the translation plugin. Can someone else try to see if they also see this working?

Hi @Tigerlady,
I had part of your fix figured out already. I'll look into the rest in the coming days and get back to you.

Hi @Tigerlady,
With your help I managed to fix the issue and while testing I also improved some other small area's of the plugin.
A new version with these fixes is available now: 4.1.1

Just getting back into this finally. Using @Tigerlady's code above I now have the option for switching languages!! I am not seeing anything when I am trying to map the content... maybe I missed a setting?

Screen Shot 2023-05-01 at 4 27 05 PM

Bruce when you click the + select sign, it should open up so you can search the other language for the page.
image

Ahhhhhh When I hit the plus sign, it asks me to save the draft. From there, if I hit NO it will bring up the search area. Got it. Thank you!

No problem, it works a bit differently from the previous version on how to get to it. But it does work well once you've figured it out.

Had a request from a client that would like to load a default language based on the browser locale. Has anyone put this into play?

Sounds like something you might want to handle client side with a redirect. Or is the locale passed to the server in a header? (I have no experience with it)

Bruce, I haven't tried that yet, but my initial thought would be to put an if statement at the top of the page, something like getLocale(). Not sure if that would work. However, I also add other things to the HTML header like this for when they switch languages; it renders properly.
<cfif m.siteConfig('siteid') eq "kr"> <html lang="ko"<cfif $.hasFETools()> class="mura-edit-mode"</cfif>> <cfelseif m.siteConfig('siteid') eq "de"> <html lang="de"<cfif $.hasFETools()> class="mura-edit-mode"</cfif>> <cfelseif m.siteConfig('siteid') eq "es"> <html lang="es_MX"<cfif $.hasFETools()> class="mura-edit-mode"</cfif>> <cfelse> <html lang="en"<cfif $.hasFETools()> class="mura-edit-mode"</cfif>> </cfif>

<head> <cfif m.siteConfig('siteid') eq "kr"> <meta http-equiv="content-language" content="ko"> <meta http-equiv="content-type" content="text/html; charset=euc-kr"> <cfelse> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> </cfif>

The top part is to detect when they have switched languages so the editor knows what language they are in. The second part after the head tag is to render the Korean language properly in the browser. Depending on your language, you may or may not need any of that.

Going back to your original question, I did a little research, and if you are on a Windows server, you may be able to do a redirect in the web config file.

If you get it figured out, please post the solution as it would be a great help. Thank you.

Thank you! I will keep you posted as I test this a bit more.