This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 3 replies, has 2 voices.

Last updated by Bruno Kos 3 weeks, 6 days ago.

Assigned support staff: Bruno Kos.

Author Posts
September 18, 2019 at 6:39 am #4592717

andreB-25

Hello,
I'm trying to stringtranslate my custom template with aall the posts and content currently in it and i was told that i need to write like 2 lines of code to do that. In your doc, i only find the _e function solution, but that means i need to review thousends of codelines and add the _e function to each of those. Is there no faster way? I'm running on the latest WordPress and WPML versions at this time.

Thanks for your help

September 18, 2019 at 7:31 am #4593225

Bruno Kos
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+02:00)

Hi,

Can you tell me if you seen my messages I posted within chat?
https://wpml.org/forums/topic/using-string-translater-for-my-custom-theme/#post-4593053

I was asking whether you are trying to translate the theme strings or the content you written in fact, like pages, posts, etc?

Regards,
Bruno Kos

September 19, 2019 at 10:56 am #4603853

andreB-25

Hello,
I did manage to add them to the stringtranslator, i missunderstood that i only needed to use the function on hard strings, i thought i had to add it somehow in the query aswell but alright, thanks for that.

My next question is about adding my a custom menuitem for the language switcher, here is what i prepared so far.

<li class="nav-item dropdown py-md-2"
                    role="presentation">
                    <a class="nav-link dropdown-toggle"
                       data-toggle="dropdown"
                       href="#" role="button" aria-haspopup="true"
                       aria-expanded="false">
                        <?php if(ICL_LANGUAGE_CODE=='de'){ echo 'Deutsch';} else {echo 'English';}?>
						<span class="caret"></span>
                    </a>
                    <div class="dropdown-menu"
                         aria-labelledby="dropdownMenu1">
                        <a class="dropdown-item" href="#">English</a>
                        <div class="dropdown-divider"></div>
                        <a class="dropdown-item" href="#">Deutsch</a>
                    </div>
                </li>

I didnt find any solution yet on to how i take the current url, remove the ?lang=de and replace it with ?lang=en and vice versa, can you help me out on this problem?

September 19, 2019 at 1:07 pm #4605059

Bruno Kos
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+02:00)

Hi,

Is there a reason why you haven't tried this yet?

https://wpml.org/documentation/getting-started-guide/language-setup/language-switcher-options/#separate-sections-for-different-kinds-of-language-switchers

You can simply assign language switcher to any menu and style it as you wish.

Or you can code the language switcher, as described here:
https://wpml.org/documentation/getting-started-guide/language-setup/custom-language-switcher/

Regards,
Bruno Kos