简体   繁体   English

Joomla语言切换器替代

[英]Joomla language switcher override

I'm trying to force the language swither module not to redirect to the home page if there is no menu item associations in Joomla 2.5. 如果Joomla 2.5中没有菜单项关联,我试图强制语言切换模块不要重定向到主页。 I would just like to change country code in the current URL. 我只想更改当前URL中的国家/地区代码。

So that 'my-domain.com/ en /menu?view=cat&id=1' translate to: 'my-domain.com/ de /menu?view=cat&id=1' and so on ... 这样'my-domain.com/ zh / menu?view = cat&id = 1'转换为:'my-domain.com/ de / menu?view = cat&id = 1'等,依此类推...

I guess I should modify modLanguagesHelper class but do not know how to create a required $language->link to work properly through JRoute. 我想我应该修改modLanguagesHelper类,但不知道如何创建必需的$ language-> link才能通过JRoute正常工作。

Any help is appreciated! 任何帮助表示赞赏!

Joomla usually does that by default. Joomla通常默认情况下会这样做。 It seems strange that it doesn't with the approach you have followed. 奇怪的是,它与您所采用的方法不同。

Although, reading the comments you left, I understand it's not an easy task and you have already built quite a big part of the website, to go back to structure. 尽管阅读您留下的评论,但我知道这不是一件容易的事,并且您已经建立了网站的很大一部分,以恢复结构。

If I were you, I would write a small custom module to change the lang=xx or /xx/ in the URL, and redirect the user to the language they want. 如果您是我,我会写一个小的自定义模块来更改URL中的lang = xx或/ xx /,并将用户重定向到他们想要的语言。 If you need help on that, feel free to comment below. 如果您需要帮助,请在下面发表评论。

As per your question, I would personally go with simple string manipulation. 根据您的问题,我个人会进行简单的字符串操作。 Since you are really familiar with PHP (taking into consideration that you have written your own custom component), it should be a piece of cake for you, to: 由于您真的很熟悉PHP(考虑到您已经编写了自己的自定义组件),因此,对于您来说,这应该是小菜一碟:

  • Get the current URL 获取当前URL
  • Get the current language tag 获取当前的语言标签
  • Replace the instances of lang=en with lang=de (example languages, you get the point) 将lang = en的实例替换为lang = de(示例语言,您明白了)
  • Replace the instances of yoursite.com/en/ with yoursite.com/de/ 将yoursite.com/en/的实例替换为yoursite.com/de/
  • Print the custom links, flags or whatever you are going to use. 打印自定义链接,标志或您将要使用的任何内容。

It's not the suggested scenario, but you can really make a usable module if you also add: 这不是建议的方案,但是如果您还添加以下内容,则可以真正创建一个可用的模块:

  • An option for the administrator to write the language codes to use (to allow for later additions) 管理员用来编写要使用的语言代码的选项(以便以后添加)

And make sure that you get the site name dynamically, and then you may also have a module that could be published in the JED to help others in the same situation like you! 并确保您动态获取站点名称,然后您可能还会有一个模块可以在JED中发布,以帮助处于类似情况的其他人!

使用 Joomla 语言覆盖创建自定义<title>标签&lt;/div&gt; </title><div id="text_translate"><div><aside class="s-notice s-notice__info post-notice js-post-notice mb16 js-bounty-notification" role="status"><div class="d-flex fd-column fw-nowrap"><div class="d-flex fw-nowrap"><div class="flex--item mr8"><svg aria-hidden="true" class="svg-icon iconClock" width="18" height="18" viewbox="0 0 18 18"><path d="M9 17c-4.36 0-8-3.64-8-8 0-4.36 3.64-8 8-8 4.36 0 8 3.64 8 8 0 4.36-3.64 8-8 8Zm0-2c3.27 0 6-2.73 6-6s-2.73-6-6-6-6 2.73-6 6 2.73 6 6 6ZM8 5h1.01L9 9.36l3.22 2.1-.6.93L8 10V5Z" /></svg></div><div class="flex--item wmn0 fl1 lh-lg"><div class="flex--item fl1 lh-lg"> <a href="https://stackoverflow.com/help/bounty" rel="nofollow noreferrer">赏金</a>将<span title="2021-12-17 13:23:39Z">在 4 天后</span>到期。 此问题的答案有资格获得<span class="s-badge__bounty d-inline px4 py2 ba bc-transparent bar-sm fs-caption va-middle">+100</span>声望赏金。 <a href="/users/13886738/nick" rel="nofollow noreferrer">尼克</a>想引起更多关注这个问题:<blockquote><div> 我被困在这个问题上,修复它真的很重要。 我在 joomla 堆栈上发布了这个,但我在那里没有太多代表(我也不确定我在那里得到了足够的关注)</div></blockquote></div></div></div></div></aside></div><p> 我有这段代码已经在我需要完成的页面上运行。 (整个Joomla 3.9站点是自定义代码、组件等的科学怪人)</p><pre> $placeholder_country = JText::_('COM_ACME_PLACEHOLDER_COUNTRY_'.strtoupper(str_replace('-','_',$var['country']))); if($placeholder_country === 'COM_ACME_PLACEHOLDER_COUNTRY_'.strtoupper(str_replace('-','_',$var['country'])) ||;$placeholder_country) $placeholder_country = '': $article-&gt;text = JString:,str_ireplace("{%placeholder_country%}", $placeholder_country; $article-&gt;text);</pre><p> 我尝试添加以下内容以查看是否可以使用相同的方式设置标题。</p><pre> $placeholder_country = JText::_('titlenick_'.strtoupper(str_replace('-','_',$var['country']))); if($placeholder_country === 'titlenick_'.strtoupper(str_replace('-','_',$var['country'])) ||;$placeholder_country) $placeholder_country = '': $document-&gt;setTitle = JString:,str_ireplace("{%placeholder_country%}", $placeholder_country; $article-&gt;text);</pre><p> 意思是,我将 go 放入 Joomla 语言覆盖部分,添加语言常量,例如“TITLENICK_PERU”</p><p> 在“文本”Id 中输入我想要的页面标题。 例如“便宜的秘鲁假期”。</p></div> - Use the Joomla Language override to create custom <title> tags

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Joomla语言切换器修改 - Joomla language switcher modification Symfony 2.4中的语言切换器 - A language switcher in Symfony 2.4 PHP语言切换器? - PHP language switcher? Javascript语言切换器 - Javascript language switcher PHP语言切换器 - Language switcher in PHP 如何触发语言切换器 - How to trigger language switcher 使用 Joomla 语言覆盖创建自定义<title>标签&lt;/div&gt; </title><div id="text_translate"><div><aside class="s-notice s-notice__info post-notice js-post-notice mb16 js-bounty-notification" role="status"><div class="d-flex fd-column fw-nowrap"><div class="d-flex fw-nowrap"><div class="flex--item mr8"><svg aria-hidden="true" class="svg-icon iconClock" width="18" height="18" viewbox="0 0 18 18"><path d="M9 17c-4.36 0-8-3.64-8-8 0-4.36 3.64-8 8-8 4.36 0 8 3.64 8 8 0 4.36-3.64 8-8 8Zm0-2c3.27 0 6-2.73 6-6s-2.73-6-6-6-6 2.73-6 6 2.73 6 6 6ZM8 5h1.01L9 9.36l3.22 2.1-.6.93L8 10V5Z" /></svg></div><div class="flex--item wmn0 fl1 lh-lg"><div class="flex--item fl1 lh-lg"> <a href="https://stackoverflow.com/help/bounty" rel="nofollow noreferrer">赏金</a>将<span title="2021-12-17 13:23:39Z">在 4 天后</span>到期。 此问题的答案有资格获得<span class="s-badge__bounty d-inline px4 py2 ba bc-transparent bar-sm fs-caption va-middle">+100</span>声望赏金。 <a href="/users/13886738/nick" rel="nofollow noreferrer">尼克</a>想引起更多关注这个问题:<blockquote><div> 我被困在这个问题上,修复它真的很重要。 我在 joomla 堆栈上发布了这个,但我在那里没有太多代表(我也不确定我在那里得到了足够的关注)</div></blockquote></div></div></div></div></aside></div><p> 我有这段代码已经在我需要完成的页面上运行。 (整个Joomla 3.9站点是自定义代码、组件等的科学怪人)</p><pre> $placeholder_country = JText::_('COM_ACME_PLACEHOLDER_COUNTRY_'.strtoupper(str_replace('-','_',$var['country']))); if($placeholder_country === 'COM_ACME_PLACEHOLDER_COUNTRY_'.strtoupper(str_replace('-','_',$var['country'])) ||;$placeholder_country) $placeholder_country = '': $article-&gt;text = JString:,str_ireplace("{%placeholder_country%}", $placeholder_country; $article-&gt;text);</pre><p> 我尝试添加以下内容以查看是否可以使用相同的方式设置标题。</p><pre> $placeholder_country = JText::_('titlenick_'.strtoupper(str_replace('-','_',$var['country']))); if($placeholder_country === 'titlenick_'.strtoupper(str_replace('-','_',$var['country'])) ||;$placeholder_country) $placeholder_country = '': $document-&gt;setTitle = JString:,str_ireplace("{%placeholder_country%}", $placeholder_country; $article-&gt;text);</pre><p> 意思是,我将 go 放入 Joomla 语言覆盖部分,添加语言常量,例如“TITLENICK_PERU”</p><p> 在“文本”Id 中输入我想要的页面标题。 例如“便宜的秘鲁假期”。</p></div> - Use the Joomla Language override to create custom <title> tags PHP多语言,$ _SESSION和语言切换器 - PHP multilingual, $_SESSION and language switcher 如何在标题中放置语言切换器? - How to place language switcher in header? 语言切换器块在drupal中不起作用 - Language switcher Block is not working in drupal
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM