Custom language strings for style creation.

https://www.phpbb.com/ideas/
Post Reply
Author:
Mannix_
Posted:
Tue Nov 05, 2019 2:43 pm
Rating:
Status:
New
User avatar
Mannix_
Registered User
Posts: 570
Joined: Sun Oct 25, 2015 2:56 pm
Contact:

Custom language strings for style creation.

Post by Mannix_ » Tue Nov 05, 2019 2:43 pm

Would it be possible to enable mostly for style creators or anyone that want to customize his style ability to add custom language string with the style? Right now you would need create an extension with those custom language strings for them to work and some board owners aren't to keen to add an extension (extra load on the server/needs more precious space) just for the style they want to use. So if there was a language folder inside the style folder it would be much easier to add custom language strings to your style without the need of an extension. This would open more possibilities for customization when creating a style meaning better styles and that would greatly benefit the community imho.
-=-=-=-=-=-=-=-=-=-=-=-=-My Styles-=-=-=-=-=-=-=-=-=-=-=-=-
HexagonHexagonRebornCleanSilverProject Durango
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Want me to port a style to 3.2.x etc. contact me here or on twitter.

User avatar
david63
Registered User
Posts: 16718
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Name: David Wood
Contact:

Re: Custom language strings for style creation.

Post by david63 » Tue Nov 05, 2019 3:31 pm

How would you propose handling translations?
David
Remember: You only know what you know and - you don't know what you don't know!
My CDB Contributions | How to install an extension
I will not be accepting translations for any of my extensions in Github - please post any translations in the appropriate topic.
No support requests via PM or email as they will be ignored

User avatar
Mannix_
Registered User
Posts: 570
Joined: Sun Oct 25, 2015 2:56 pm
Contact:

Re: Custom language strings for style creation.

Post by Mannix_ » Tue Nov 05, 2019 3:51 pm

david63 wrote:
Tue Nov 05, 2019 3:31 pm
How would you propose handling translations?
Same as phpbb? main folder called language and inside sub folders for each language if that's what you are asking. Don't know how it would be done behind the scenes code wise.
-=-=-=-=-=-=-=-=-=-=-=-=-My Styles-=-=-=-=-=-=-=-=-=-=-=-=-
HexagonHexagonRebornCleanSilverProject Durango
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Want me to port a style to 3.2.x etc. contact me here or on twitter.

User avatar
Dan Stylez
Registered User
Posts: 276
Joined: Tue Jan 16, 2018 6:17 am

Re: Custom language strings for style creation.

Post by Dan Stylez » Tue Nov 05, 2019 5:20 pm

The ability to add language to styles would be great,

There are so many links on the home page that could be put into added specific menus, i/e "forum info" for terms/privacy/faq/the team/contact us, etc - forum info needs to be hard coded, there are lots of other handy little things authors could add to their styles too to benefit the user.

If Mannix's idea is not possible... I wonder if style authors who have created a style customiser extension for a specific style - could ever have it validated and listed only on that specific validated style page?
Image
When you’re hot, you’re hot... when you’re cold, you’re not hot.

User avatar
EA117
Registered User
Posts: 1081
Joined: Wed Aug 15, 2018 3:23 am
Contact:

Re: Custom language strings for style creation.

Post by EA117 » Tue Nov 05, 2019 5:54 pm

You might have already seen this recent discussion, and are proposing this phpBB Ideas as a better and more formalized approach that styles could employ. But I'm mentioning it just in case you're also thinking "it can't be done currently."


To the point of "could this be formalized to make support easier":

Yes, if the style was able to have a "language" directory into which the original style author and/or contributors could place translations for unique style-introduced strings, this would improve the style author's ability to create and manage such new strings or messages.

It doesn't change anything about the fact that the style and/or its contributors still have the burden of providing the translations; it only changes the "where" and "how" of maintaining and using those translations. It makes the "how" someone would contribute or define strings more similar if not identical to how they are provided for extensions or phpBB itself, not withstanding that they will be style-specific.

Similar to how phpBB's own language string search mechanism will "search enabled extensions for a matching string" (at least specifically in the case of "Permissions"-related strings; maybe it happens at other times too), that same type of "transparently include a search against the style's language directory" seems like what is being proposed here. i.e. If a string is being referenced during template processing, a search of the style's language directory should be included in trying to resolve the referenced string name.

Style inheritance must also be honored here: If a child's language directory doesn't provide the string, it may be because a parent style's language directory provides it.

Maybe something that is unique here, or perhaps should be part of that proposal: If the style doesn't have a language directory for the current language, the search should fall back to the "en" directory or whatever first-available language folder is present.

i.e. If the style didn't provide a particular translation, don't simply display a blank string as though the variable is undefined. Fall back to English or whichever language the style did supply. I don't believe that's something which happens in phpBB's "normal" language support (things die when a language pack doesn't correctly provide all strings), so it might need to be specifically part of the plan here.

Maybe it was already OP's intention here too, but regardless: Perhaps maximum flexibility would be achieved if a style could also override phpBB's own language pack strings. e.g. If both the phpBB language pack and the style defined a value for NO_ONLINE_USERS, the style's definition for how this string needs to be displayed when this particular style is selected is the one that needs to take precedence.


To the point of "it is possible to provide new language-specific strings in a style today":

The simplest approach being to make the style template directly provide & decide which translation to present. For example:

Code: Select all

<dd>
	<!-- IF S_USER_LANG eq 'fr' -->
	Ceci est mon nouveau message.
	<!-- ELSEIF S_USER_LANG eq 'de' -->
	Das ist meine neue Nachricht.
	<!-- ELSE -->
	This is my new message.
	 <!-- ENDIF -->
</dd>
The down-side of course being that any additional translations have to be provided in-line within the template, rather than in a separate or language-specific file. The previously cited post did propose that CSS might be a way to "put all the translations into their own separate file" to be re-used across the styles templates, and/or leveraging the existing T_STYLESHEET_LANG_LINK or T_THEME_LANG_NAME for achieving it.


edit: Added references to support for parent styles and for overriding phpBB-defined messages.
Last edited by EA117 on Tue Nov 05, 2019 6:27 pm, edited 1 time in total.

User avatar
warmweer
Registered User
Posts: 3055
Joined: Fri Jul 04, 2003 6:34 am
Location: Van Allen Belt ... well actually Belgium

Re: Custom language strings for style creation.

Post by warmweer » Tue Nov 05, 2019 6:24 pm

Nothing to add but a YES vote. (although, I must say I agree with the language part being included in the style directory itself (and not in the language directory.)
The year is 2192. The British Prime Minister visits Brussels to ask for an extension of the Brexit deadline. No one remembers where this tradition originated, but every year it attracts many tourists from all over the world.

User avatar
Mannix_
Registered User
Posts: 570
Joined: Sun Oct 25, 2015 2:56 pm
Contact:

Re: Custom language strings for style creation.

Post by Mannix_ » Tue Nov 05, 2019 7:11 pm

EA117 wrote:
Tue Nov 05, 2019 5:54 pm
You might have already seen this recent discussion, and are proposing this phpBB Ideas as a better and more formalized approach that styles could employ. But I'm mentioning it just in case you're also thinking "it can't be done currently."
Yes I've seen that discussion but the idea was in my head way earlier when I was in development of one of my styles :)
EA117 wrote: To the point of "could this be formalized to make support easier":

Yes, if the style was able to have a "language" directory into which the original style author and/or contributors could place translations for unique style-introduced strings, this would improve the style author's ability to create and manage such new strings or messages.

It doesn't change anything about the fact that the style and/or its contributors still have the burden of providing the translations; it only changes the "where" and "how" of maintaining and using those translations. It makes the "how" someone would contribute or define strings more similar if not identical to how they are provided for extensions or phpBB itself, not withstanding that they will be style-specific.
Yes exactly I was thinking that. If extension creators can be "burdened" with providing the translation style creator can be too but here it's not somewhat mandatory as is with extensions because not every style creator is gonna add his own language strings.
EA117 wrote: Similar to how phpBB's own language string search mechanism will "search enabled extensions for a matching string" (at least specifically in the case of "Permissions"-related strings; maybe it happens at other times too), that same type of "transparently include a search against the style's language directory" seems like what is being proposed here. i.e. If a string is being referenced during template processing, a search of the style's language directory should be included in trying to resolve the referenced string name.
Exactly nothing to add here
EA117 wrote: Style inheritance must also be honored here: If a child's language directory doesn't provide the string, it may be because a parent style's language directory provides it.
Not sure what kind of situation you have in mind?
EA117 wrote: Maybe something that is unique here, or perhaps should be part of that proposal: If the style doesn't have a language directory for the current language, the search should fall back to the "en" directory or whatever first-available language folder is present.

i.e. If the style didn't provide a particular translation, don't simply display a blank string as though the variable is undefined. Fall back to English or whichever language the style did supply. I don't believe that's something which happens in phpBB's "normal" language support (things die when a language pack doesn't correctly provide all strings), so it might need to be specifically part of the plan here.
Yes falling back to english would be the best option
EA117 wrote: Maybe it was already OP's intention here too, but regardless: Perhaps maximum flexibility would be achieved if a style could also override phpBB's own language pack strings. e.g. If both the phpBB language pack and the style defined a value for NO_ONLINE_USERS, the style's definition for how this string needs to be displayed when this particular style is selected is the one that needs to take precedence.
That may not even be a problem because style author can add his own string like PR_NO_ONLINE_USERS PR being a prefix/abbreviation of the style name. So there would be no conflict somewhere else in the style.
EA117 wrote: To the point of "it is possible to provide new language-specific strings in a style today":

The simplest approach being to make the style template directly provide & decide which translation to present. For example:

Code: Select all

<dd>
	<!-- IF S_USER_LANG eq 'fr' -->
	Ceci est mon nouveau message.
	<!-- ELSEIF S_USER_LANG eq 'de' -->
	Das ist meine neue Nachricht.
	<!-- ELSE -->
	This is my new message.
	 <!-- ENDIF -->
</dd>
The down-side of course being that any additional translations have to be provided in-line within the template, rather than in a separate or language-specific file. The previously cited post did propose that CSS might be a way to "put all the translations into their own separate file" to be re-used across the styles templates, and/or leveraging the existing T_STYLESHEET_LANG_LINK or T_THEME_LANG_NAME for achieving it.


edit: Added references to support for parent styles and for overriding phpBB-defined messages.
Yeah adding them in the template files is messy in my opinion and obstructs possibility of contribution by style contributors that was mentioned by you at the beginning of your post. It's easier to edit language file than template file for inexperienced user that want to help and contribute their translation and add it as pull request on github for example.
-=-=-=-=-=-=-=-=-=-=-=-=-My Styles-=-=-=-=-=-=-=-=-=-=-=-=-
HexagonHexagonRebornCleanSilverProject Durango
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Want me to port a style to 3.2.x etc. contact me here or on twitter.

User avatar
Tastenplayer
Registered User
Posts: 384
Joined: Thu Jul 03, 2014 9:20 pm
Location: Switzerland
Name: Jutta Koliofotis
Contact:

Re: Custom language strings for style creation.

Post by Tastenplayer » Tue Nov 05, 2019 7:24 pm

I'm a little skeptical if that's really possible. But since I just have the problem of the dropdown title in my style - a clear yes.
My phpBB Style Board & MoreFlowerPower 3.2.8 Screenshots & Download
Be the best version of yourself rather than a bad copy of someone else!
Excuse me for my English, but I learned the language by speaking to people and not at school.

User avatar
Gumboots
Registered User
Posts: 196
Joined: Fri Oct 11, 2019 1:59 am

Re: Custom language strings for style creation.

Post by Gumboots » Tue Nov 05, 2019 7:45 pm

Upvoted this one. It's a good idea. In fact a few weeks ago, when I first started looking around, I was surprised it wasn't already possible.
i.e. If the style didn't provide a particular translation, don't simply display a blank string as though the variable is undefined. Fall back to English or whichever language the style did supply.
Yep. It's not rocket science.

User avatar
EA117
Registered User
Posts: 1081
Joined: Wed Aug 15, 2018 3:23 am
Contact:

Re: Custom language strings for style creation.

Post by EA117 » Tue Nov 05, 2019 8:37 pm

Mannix_ wrote:
Tue Nov 05, 2019 7:11 pm
EA117 wrote: Style inheritance must also be honored here: If a child's language directory doesn't provide the string, it may be because a parent style's language directory provides it.
Not sure what kind of situation you have in mind?
If I create child_style to inherit from your_style, and copy the overall_header.html template from your_style into child_style because I have some additions I need to make, there can be language-dependent string references already in this overall_header.html which aren't "literally in the language directory of child_style." The style-specific language processing will need to be another thing which honors the style inheritance hierarchy, same as the template processing itself currently does.

Mannix_ wrote:
Tue Nov 05, 2019 7:11 pm
EA117 wrote: Perhaps maximum flexibility would be achieved if a style could also override phpBB's own language pack strings...
That may not even be a problem because style author can add his own string like PR_NO_ONLINE_USERS PR being a prefix/abbreviation of the style name. So there would be no conflict somewhere else in the style.
Agreed, and that had almost made me not include this point. If I really wanted to change how NO_ONLINE_USERS displays, I could just create my own style-specific version of that string, and reference that instead. The key addition there -- and why I went ahead and referenced it -- is that you also must provide all templates which reference that language string.

e.g. If my style intended to present all "Members" references as "Subscribers", or some similar "pervasive" change that is in line with how the style is customizing the visual presentation of the site. Without this "override phpBB language strings" precedence in the language handling, my only choice would be to provide every single template in which "Members" was referenced.

Which, if we say that's the way it's going to work, can certainly still be the way it works. But the other option was for the style to just define the string(s) which currently refer to "Member", and let the existing templates (whether part of the current style or parent style(s) we inherited from) be capable of reflecting that change.

An extension has the capability to override what an existing variable would return, and if we're choosing how a style-aware language system should behave, perhaps it at least deserves to be on the list for consideration.

Mannix_ wrote:
Tue Nov 05, 2019 7:11 pm
EA117 wrote: The simplest approach being to make the style template directly provide & decide which translation to present...
Yeah adding them in the template files is messy...
Indeed, and there was definitely no delusion to the contrary. The statement had been made that "right now you would need create an extension with those custom language strings for them to work." Which is true in context of "to create an actual template variable" for the language-dependent string.

I was just confirming that "create an extension" or such template variables wasn't the only option for how to deliver a language-dependent style change; if someone was trying to deliver one today when reading this, and might otherwise think "the only option" was to wait for whether this Idea would be implemented.

Post Reply

Return to “phpBB Ideas”