Anonymous edits have been disabled on the wiki. If you want to contribute please login or create an account.


Warning for game developers: PCGamingWiki staff members will only ever reach out to you using the official press@pcgamingwiki.com mail address.
Be aware of scammers claiming to be representatives or affiliates of PCGamingWiki who promise a PCGW page for a game key.

Topic on User talk:Andytizer

Langbar template: ideas and extension requests

23
Masked Turk (talkcontribs)

Hi Andy,

I've done some thinking about the language selector template, and essentially come up with two methods of making it work right (assuming we're working by the subpage method of translations of Article and /Article/Polski)

1. Check if each language's translation page exists

This is probably the more convoluted method, but doesn't require any extensions or anything. Essentially, I create a template that contains instances of another template for each language that we want, and if the template for that language finds that Article/SubArticleWithThatLanguageName exists, it displays.

This is the method that erepublik uses. It does work, in the end, so idk. It shouldn't be that hard to sort out.

2. Use extensions to find an article's translation subpages

The other method would result in (I'm estimating) quite a bit less code, but would require two simple parser extensions that aren't on this wiki yet:

The first gives us the ability to list subpages of an article (i.e. to find all the translations of an article). The second gives us the ability to manipulate the array that the first extension produces, and format each subpage translation for the template.

Advantages? We wouldn't have to manually add each language to some back-end template, and it'd be cleaner code. If you can be arsed, I think this would be the better option, and tbh these extensions could be useful in a bunch of other templates :) Just a thought!

Cheers, JB

Andytizer (talkcontribs)

Discussing this with JRWR at the moment, will try to finish this tonight or tomorrow.

Andytizer (talkcontribs)
Masked Turk (talkcontribs)
) I'll get to work shortly.
Andytizer (talkcontribs)

There is some kind of incompability between Array and the Vector extension (it does some funky enhancements to the skin). For now Array is disabled, will experiement a bit more later. Will let you know as soon as it's stable.

Andytizer (talkcontribs)

I think I fixed this now, Array had been loaded after Vector, and is working.

Masked Turk (talkcontribs)

Great, thanks. I was wondering where it had gone tbh :P

Masked Turk (talkcontribs)

These extensions have worked like a charm in my template: User:Masked_Turk/Sandbox/Langbar

{{Langbar}}

It'll seek out direct subpages and display them in list-form. I just need feedback on design and styling now that the functionality is all there.

Andytizer (talkcontribs)

Very nice :). I'd like to implement this straight away. It looks amazing :). Other solutions I have investigated have been much more complicated, involving interwikis or bots to maintain the subpage links, etc. so this is really a godsend.

In terms of style, I have disabled the background hover because I don't think it quite looks right. I also think a character seperator like '·' works better than | which takes too much vertical space.

I have tried to implement the {{Langbar|main}} on the Home page. I have also implemented the Polski page: Home/Polski, but it's not showing up on the main page. Can you take a look please?

Masked Turk (talkcontribs)

Unfortunately it seems that Extension:Subpage_Fun does not recognise the main article's sub-pages, which means we'll probably have to use a different method for the main article's English page: sorry about that.

I've altered the stylings to your description as best I can, can you check it's as you imagined?

Andytizer (talkcontribs)

If it's just the one-off, then we could simply create a custom table to fit on the Home page.

Andytizer (talkcontribs)

Another thought is about category translation - what's the best way to handle this? I'm assuming it'll function in the same way as pages, so I can create Game/Polski and put the Langbar in the category page. Then this will display the game pages written in Polish.

Masked Turk (talkcontribs)

You just reminded me about categories, so I've added Category:Articles with translations and [[:{{{language name}}} translations]] to the relevant parts of the template.

Regarding category pages... hmm, the template looks for subpages of the article it's in, so if you put {{Langbar|main}} in Category:Games, the template will show the link to the Polish version of the category page. I could amend the template to categorise Polish (etc.) translations in Category:Games/Polski, which would achieve what I think you're after?

Andytizer (talkcontribs)

Yes that would help thank you :).

Andytizer (talkcontribs)

Thanks that would be very helpful.

Masked Turk (talkcontribs)

Right, done that. Problem #2 with the extension is that it doesn't seem to notice subpages in Category:, Template: etc. either. Unless I'm doing it wrong. I've asked the extension creator over at mediawiki.

For now though, workaround: the category translations appear as sub-categories on the page: see Category:Games for e.g.

Andytizer (talkcontribs)

Let's wait for a response - it must be a switch to allow for these namespaces. If you don't hear anything back in a couple of days we can do a workaround.

Masked Turk (talkcontribs)

Right, I *think* I have a fix.

Delve into LocalSettings.php and append the following line to the end of the file:

$wgNamespacesWithSubpages = array_fill(0, 500, true); //enables subpages for all articles, so the extension works!
Andytizer (talkcontribs)

I've added this in now, let me know if it works!

Masked Turk (talkcontribs)

See for yourself ^_^ - Just going about removing the pl from the list, through the ingenious use of regular expression commands. Shouldn't take long.

Masked Turk (talkcontribs)
Andytizer (talkcontribs)

Great, works well on the home screen. It doesn't appear to be working on the category page though? http://pcgamingwiki.com/wiki/Category:Game

Is there any way to have the full list of languages displayed whether it is Home or Home/Polski? Is there an alternative to a link for 'Return to the English language article'?

Masked Turk (talkcontribs)
  1. Category fixed. Forgot to add the : for categories, so it added them to the categories instead of displaying them as links :P
  2. Show list of langs in subpages: Sorted. Template will link other langs if available, otherwise will link back to route article. Took quite a bit of rearrangement :P