Making WordPress.org

Opened 8 years ago

Closed 7 years ago

Last modified 4 years ago

#3935 closed enhancement (fixed)

Language specific screenshots

Reported by: f.staude Owned by:
Priority: normal Milestone:
Component: Plugin Directory Keywords: has-patch
Cc:

Description (last modified by dd32)

The captions of the screenshots can be translated.
It would be nice if I could also upload language-specific screenshots.

So screenshot-1.png as default screenshot and screenshot-1-de_DE.png or screenshot-1-es_ES.png for language specific screenshots in the selected language (In this example for German and Spanish)

Attachments (3)

3935.diff​ (2.7 KB ) - added by ck3lee 8 years ago.
3935.2.diff​ (2.8 KB ) - added by ck3lee 8 years ago.
3935.3.diff​ (4.4 KB ) - added by ck3lee 8 years ago.

Download all attachments as: .zip

Change History (14)

#1 @f.staude
8 years ago

Of course it must be called screenshot-1-de_DE.png

#2 @dd32
8 years ago

  • Description modified (diff)

#3 @ck3lee
8 years ago

  • Keywords has-patch added

Attached a patch attachment:3935.diff​ to implement support screenshots for multiple locales.

  • Extended the import plugin process to support locale in the file name as suggested.
  • Plugin page fallback to display screenshots without locale if user locale is not matched with any screenshots with locale.
Last edited 8 years ago by ck3lee (previous) (diff)

#4 @ck3lee
8 years ago

Updated with patch attachment:3935.2.diff​

  • Extended regex to support locales with variants (eg: de_DE, de_DE_informal).

#5 @dd32
8 years ago

Hey @ck3lee,

Just looking at 3935.2.diff​

  • The regex looks correct to me, although I haven't tested it yet
  • Even with the above, it looks like we're only using the first two digits of the locale? substr( $image['locale'], 0, 2 )

Consider this line up of files:

  1. screenshot-1.png
  2. screenshot-1-de_DE.png
  3. screenshot-1-de_CH.png

If the array of results was ordered exactly like that, you'd only had screenshot-1.png being used, if it was ordered 2,3,1 then for de_CH it'd only use the de_DE file.

I think the list of images needs to be reduced before the loop:
Do any images have a locale?
If so, Is our locale there? Or is a nearish locale there? (ie. look for de_CH, then de)

You should also consider this set of files, which is potentially likely:

  1. screenshot-1.png
  2. screenshot-1-de_DE.png
  3. screenshot-2.png
  4. screenshot-2-de_CH.png
  5. screenshot-3.png

#6 @ck3lee
8 years ago

Thanks, @dd32.

I've added a reduced function to better match the locale of the image with user's locale, attachment:3935.3.diff​ with the intent to have:

  • Image with fully matched locale (language, country and variance) has the highest priority.
  • Image with language matched only has second priority.
  • Then, fallback to default image without locale if no image is matched.
Last edited 8 years ago by ck3lee (previous) (diff)

#7 @dd32
8 years ago

In 8729:

Plugin Directory: Introduce localised screenshots, allowing plugins to have translated screenshots on the website and within the wp-admin plugin installer.

This works by allowing screenshots located in the /assets/ folder to define the locale of the image, eg. screenshot-1-de_DE.png or screenshot-1-ary.png.

Props ck3lee, dd32.
See #3935.

#8 @dd32
8 years ago

@ck3lee nice work!

In [8729] I've rearranged a bit of the code, and generalised it more to allow it to work with the API components.

Some things I noticed while working with the patch

  • In reduce_screenshots_with_locale() it was expecting that the new $image['locale'] field was always set, where it won't be for any older screenshot meta, In the above commit i simply flipped the first two if conditionals to account for that
  • Images with locales such as de_DE and de_CH work as intended, but de_DE_informal will fall back to de_CH if it exists as it's lower in the alphabet. I left it as-is there as it's pretty minor and no plugins yet have these anyway :)

Updating it to support the API was required as otherwise the images were duplicated within WordPress installs, you can see the API responses ​here and ​here (Note: Using those APIs directly isn't encouraged, but it's good for testing. All API clients should be using ​api.wordpress.org instead which is heavily cached).

Testing was performed with one of my test plugins, for those who would like to see it in action compare ​English to ​German to ​Moroccan Arabic.

Last edited 8 years ago by dd32 (previous) (diff)

#9 @dd32
7 years ago

  • Resolution → fixed
  • Status new → closed

I'm going to close this as fixed, if the edgecases ever cause a problem it can be fixed then.

#10 @dd32
4 years ago

#6625 was marked as a duplicate.

#11 @dd32
4 years ago

In 12474:

Plugin Directory: Use Localised images for banners if available.

See #6627, #3935.

Note: See TracTickets for help on using tickets.