How to setup content in other languages? - mediawiki

I would like to allow users to create content for their own languages. I am running a single MediaWiki instance, so I cannot set it up for one language per install.
I would like to try and format the pages like the following, where a different language version of the page has the language code appended to it.
myWiki/SomePageContent
myWiki/SomePageContent/de
myWiki/SomePageContent/fr
How can I ensure users follow this structure? Is there some setting in MediaWiki that can help with this? I have no idea what are best practices for this.
Thanks!

Best practices are to use a separate instance of MediaWiki for each language and use interwiki links to connect them. This way, users are in one language and everything works as you'd expect: if you're in the English instance, a link to [[Foo]] stays in English, and only a link to [[fr:Foo]] goes to the French Foo. It's not particularly hard to set this up even with a single server and single database, see http://www.mediawiki.org/wiki/Manual:Wiki_family. The way this appears to the user is configurable: eg. Wikipedia uses http://en.wikipedia.org/wiki/Paris, Wikitravel uses http://wikitravel.org/en/Paris.
If this is not possible for whatever reason, the next best thing to do is to set up a separate namespace for each language (eg. "de" or "fr"), and this way you can at least do eg. searches across one (or more) languages. However, users of languages other than the 'main' language still have to manually punch in the language code in front of every article name and link, so it's not nearly as user-friendly. See http://www.mediawiki.org/wiki/Manual:Namespace.

An easier way for smaller wikis is through the use of a simple template. It may not be as efficient as an extension or creating a family of wikis, which is a lot of work, but quite fast to set up.
Create a page under Template:Otherlang with the following code:
{{otherlang
|ru=Template:Otherlang:ru
}}
This template adds available translations for the page to the top through the use of flags.
To prevent issues, this template must be placed '''at the very beginning of a page'''.
Tip! When contributing a new translation to a document that already has other translations, please carry over the existing translations to the otherlang template of your contributed page. This way all multilingual pages are linked.
== Syntax ==
{{otherlang
| noborder=true (OPTIONAL)
| title=localized page display title
| lang=page:lang
| lang2=page:lang2
| etc...
}}
Warning! Do not include the language of the current page. This will only confuse readers.
=== Example ===
On a page called [[Template:Otherlang]]:
{{otherlang
| title=Template:Otherlang
| ru=Category:Programming:ru
}}
Note that:
* The language "en" is not included, as it is the language of the page that template is being used on.
* title is assigned the translated name of the page, and will appear as the display title (heading) for the page. This can replace the existing {{wrongtitle}} and {{DISPLAYTITLE}} templates currently in common use.
* The English page has no suffix.
== Available Languages ==
{| class="table table-bordered" border="2" cellpadding="7"
! Language
! Syntax
! Result
|- id="en"
|English
|en=Page_name
|[[File:En.png]]
|- id="ru"
|Russian
|ru=Page_name:ru
|[[File:Ru.png]]
|}
{{#if: {{{title|}}} | {{DISPLAYTITLE:{{{title}}}}} }}{{#if: {{{en|}}} | '''[[File:En.png|alt=English|link={{{en}}}]]''' }} {{#if: {{{ru|}}} | [[File:Ru.png|alt=Русский|link={{{ru}}}]] }}
Then within each English article, paste use the following code to get a flag to show up, representing the respective language.
{{otherlang
| title=Tutorials/Galacticraft Getting Started Guide
| ru=Tutorials/Galacticraft_Getting_Started_Guide/ru
}}
An example of this can be found here. If you click on the Russian flag to the right you will find a Russian translation of the article.

anyone interested, you might wanna try this
http://www.mediawiki.org/wiki/Help:Extension:Translate
when this page
myWiki/SomePageContent
is translated to German, it will create the link like this:
myWiki/SomePageContent/de
and so on :)

Related

React and multilingual site: good pratices / SEO

I have a site done with React. On this site, two languages are available: 'en' and 'fr'. Here is how I implement it:
When the user comes on my site for the first time, I determine the language from its browser and I redirect it to www.mysite.com/fr or www.mysite.com/en.
The user is also free to change the language or directly access to the URL containing the language (example: www.mysite.com/fr).
Each time the language change, I store it in the local storage. This way, the user can comeback to www.mysite.com and I will redirect him to the correct URL containing the language (example: www.mysite.com/fr).
I don't specify 'lang' attribute on 'html' tag in my 'index.html' but when I know the language, I use Javascript to add this attribute dynamically.
I defined two 'hreflang' in the 'index.html'.
I already noticed two small problems with this implementation:
When I analyze my site with https://validator.w3.org/, I've got a warning telling me that 'lang' attribute is missing. I guess, this validator doesn't execute the Javascript. Can I considered it as a false positive ?
The browser extension 'Google Translate' seems to consider www.mysite.com/fr as an English page. I guess the extension doesn't wait enough to see the dynamic update of 'lang' attribute.
Is there is a way to avoid these problems ? Do you see other problems in my implementation ?

Referencing data from one article on another

(For the downvote: the reason I am asking on Stack Overflow is because this is a problem involving "programming" with MediaWiki's template system)
I am looking for a way of including data on a MediaWiki article page, such that the data values can be referenced from other pages as well, without needing to duplicate the data on the other pages. Preferably without installing extra extensions.
What I am after is the ability to create an article page that looks like this:
<!-- This page is 'Example' in the main namespace -->
{{Infobox
| CreationDate = 2015-01-01
| CreatedBy = John Smith
}}
This article is about the item created by {{d|CreatedBy}}.
When this page is viewed in the browser, it should appear like this:
+------------------------+
| Example |
| Created on: 2015-01-01 |
| Created by: John Smith |
+------------------------+
This article is about the item created by John Smith.
And then on another page, I can reference the data in the above 'Example' page, like this:
* Example created by {{d|Example|CreatedBy}} on {{d|Example|CreationDate}}
Which will appear like this:
* Example created by John Smith on 2015-01-01
The typical use for this is to place the data on the article page, then be able to provide lists which are richer than you can achieve by using categories. Currently all the data on the lists is duplicated, so if it is ever changed it needs to be updated in two places - both within the article and in the "rich list".
I think I have worked out how to do this. Firstly, the correct solution seems to be to use Semantic MediaWiki, an extension designed for using MediaWiki for data storage. However in normal MediaWiki, this can be achieved as follows.
Page Template:D:
{{#if:{{{2|}}}|{{:{{{1}}}|{{{2}}}}}
| {{:{{FULLPAGENAME}}|{{{1}}}}}
}}
This allows {{d|Page|Field}} and {{d|Field}} to work as in the original question.
The infobox code also needs to be changed so that it is surrounded by this:
{{#if:{{{1|}}}|{{#ifeq:{{{1}}}|_valid|1|{{{{{{1}}}|}}}}}|
<!-- Existing infobox goes here -->
}}
This makes the infobox data-enabled. It means you can treat pages with one of these infoboxes on it as a template, and include it in another page. This is what Template:D does - it includes the whole article as a template, and this bit of code in the infobox ensures that instead of the entire page content being included at the Template:D point, only the field of interest gets included.
It also adds a special field called _valid with a value of 1 which can be used to detect pages that contain a valid infobox or not. If you make sure {{d|Pagename|_valid}} is equal to 1 (e.g. with {{#ifeq:...}}) before using any fields on that page, then you will get correct data. This is important because if the page you are using does not have a data-enabled infobox, then each Template:D occurrence will embed the entire contents of the page!
Last of all, each infobox has to be changed to be entered like this:
<onlyinclude>{{My Infobox|{{{1|}}}
| Field1 = Value1
| Field2 = Value2
| etc.
}}</onlyinclude>
This is required because MediaWiki can't embed <onlyinclude> tags within templates. The |{{{1|}}} at the end of the infobox name is used to pass the field parameter from Template:D through the article page and onto the infobox template itself.
Here is a working example of this:
Template:D
Data-enabled Infobox
List of pages, with content extracted from each page's infobox - note this page uses a custom {{#foreach:}} command to repeat wikitext for each page in a category, where {{#i:}} is replaced with the name of the page in each loop iteration. So {{d|{{#i:}}|Example}} is used to extract the Example field from the page in the current loop iteration.

How to query/limit a transclusion when including the talk page?

As the tag implies, I am using MediaWiki as wiki-software. I would like to include the talk page/discussion into the page the talk/discussion is about.
I figured out how to include the talk page as a whole already doing something like this fo example (don't bother with the German notation): {{Diskussion:Test}} which add the talk page of the article Test.
The next step would be to limit the output to e.g. the 5 most recent talk "posts" (they are rather gouped under 2nd-grade headlines, I presume). Insertin of special pages can be limited by using additional parameters like so: {{Special:RecentChanges/days=5,limit=40}} as mentioned in MediaWiki help articles. However, these parameters obviously don't work when including the talk page because it is a single page/element. {{Diskussion:Test/days=5,limit=40}} is not even parsed.
Any hints and examples ae appreciated, although I prefer not to use extensions IF POSSIBLE.
The usual way to do this is to edit [[Diskussion:Test]] by adding appropriate noinclude (or onlyinclude) tags:
<noinclude>
blabla
</noinclude>
== The ==
...
== sections ==
...
== I ==
...
== want==
...
== transcluded ==
...
Now {{Diskussion:Test}} won't transclude the older stuff. This is the cleanest solution but might be tedious to do on many pages: you could automate this with a bot.
There are countless on-wiki solutions possible, for instance you could transclude everything and then use JavaScript to hide "excess" sections; or you could wrap all talk page discussions in a template, which then shows only the latest X when transcluded in subject namespace.
As for "proper" solutions, perhaps you're looking for a discussion extension. If you're brave you could test LiquidThreads, add threads directly on the page (rather than talk) and set up autoarchiving as you wish.

Semantic MediaWiki {{#ask}} - how to show source value instead "redirect name"?

I have a page(such as: Air Canada), in page, there is a property IATA, value is "AC".
Then, in Main_Page, I used:
{{#ask: [[Category:Airline]]
| ?IATA
}}
to list. (#ask is a feature in Semantic mediawiki extension)
It can work OK.
But, if I created a redirect page(AC) to "Air Canada", then, the string "AC"(listed in Main_Page) will be changed to "Air Canada".
So, my question is how to disable this translator?
It sound to me like you should use make the property IATA use the type text (add [[Has type::Text]] to the page Property:IATA. Otherwise the wiki will assume the type page, and unless you want to have specific pages about each IATA code, separate from the airline pages, that's not what you want.
And to answer you question: You can set $smwgQEqualitySupport = SMW_EQ_NONE; in LocalSettings.php to disable the functionality you are talking of, but doing so would be quite odd from a user's point of view, as redirects are basically a kind of aliases, and if the alias works in the MediaWiki world, you want it to work in the same way in the Semantic MediaWiki world.

Mediawiki 1.16: Template documentation example usage

I'm writing template documentation for a wiki and wanted to include a working example of the template. However, I wrote the template to auto-categorize various fields and the entire template itself is also auto-categorized.
This means if I simply call on the template, it will categorize the doc page...and because the actual template page transcludes the doc page, the template page will also be categorized.
Is there a way to prevent these categories from automatically kicking in?
Something like the following should do the trick. Wrap the categorization in your template inside a parserfunction:
{{#ifeq: {{NAMESPACE}} | Help || [[Category:Some_Category]] }}
This sets the category when the template is transcluded onto a page that is not in the "Help" namespace.
Another option is to allow a parameter such as demo to avoid including the category.
If you don't mind being slightly cryptic, you could do the category in the template as {{{cat|[[Category:Some_Category]]}}}; then specifying the parameter as {{my template|cat=}} will prevent the category inclusion.
I'm not sure if I understand the question completely (what is "auto-categorize various fields"?). I am assuming here that you want to show a template "in action" on a documentation page - without attaching some categories (those categories the documentation page usually attaches to articles using this template) to the documentation page.
So
<onlyinclude>[[Category:Some_Category]]</onlyinclude>
will not do the job - as the template is in fact included. Right?
Try passing a parameter categorize=false to the template to indicate that categories are not to be attached in this case:
{{#ifeq:{{{categorize|}}}|false||[[Category:Some_Category]]}}
The double pipe after "false" means: if(categorize==false) then (empty), else [[Category:Some_Category]] - i.e. it is an equivalent construction for if(NOT(categorize==false))...
Good luck and thanks for all the fish,
Achim