Change text without changing language-files

Discussion forum for Extension Writers regarding Extension Development.
Post Reply
cangor
Registered User
Posts: 58
Joined: Thu Oct 28, 2010 1:56 pm

Change text without changing language-files

Post by cangor » Wed Jan 10, 2018 8:57 am

Hello,

I use an extention (for example phpbb-gallery) and want to change a text in it, for example I want to change 'GALLERY' => 'Gallery' in /ext/phpbbgallery/core/language/en/info_acp_gallery.php to 'GALLERY' => 'My gallery of cars'.

Of course I could change the language-file itself inside the extention, but updating the extention would overwrite my changes. Is there any place where I can put my changes so that they won't be overwritten (inside my style for example)?

User avatar
david63
Jr. Extension Validator
Posts: 14079
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Name: David Wood
Contact:

Re: Change text without changing language-files

Post by david63 » Wed Jan 10, 2018 9:12 am

cangor wrote:
Wed Jan 10, 2018 8:57 am
Is there any place where I can put my changes so that they won't be overwritten (inside my style for example)?
Not really with any guarantee of success. One language file will overwrite another language file where there is the same language variable in both files but unless to can guarantee the order in which these files are always loaded then you cannot guarantee the outcome.

The only way that I can thing of is if there is a suitable event in the main extension where you could add/change the language variable in your own extension.

You are probably better off asking this in the support topic for the Gallery extension.
cangor wrote:
Wed Jan 10, 2018 8:57 am
but updating the extention would overwrite my changes
Npt sure what that means.
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
warmweer
Registered User
Posts: 963
Joined: Fri Jul 04, 2003 6:34 am
Location: Van Allen Belt ... well actually Belgium

Re: Change text without changing language-files

Post by warmweer » Wed Jan 10, 2018 9:12 am

cangor wrote:
Wed Jan 10, 2018 8:57 am
Is there any place where I can put my changes so that they won't be overwritten (inside my style for example)?
Your reasoning isn't logical in that respect because any update to the style would also overwrite the changes you made.
Just make a mental note (or keep a workflow in a document) about the actions you have to undertake when updating any extensions (or even phpBB version for that matter).
A bug is a feature that hasn't made it to the manual (yet)

User avatar
kasimi
Extension Customisations
Extension Customisations
Posts: 2760
Joined: Sat Sep 10, 2011 7:12 pm
Location: Germany
Contact:

Re: Change text without changing language-files

Post by kasimi » Wed Jan 10, 2018 9:32 am

As David already hinted at, you can put 'GALLERY' => 'My gallery of cars', in a language file of your own extension, use the same event where the Gallery extension loads that language file but with a lower priority so that your event is handled after (or basically any other event that is triggered at a later point but before the language key is used), and load your own language file there. This will make your language key overwrite the Gallery's one.

cangor
Registered User
Posts: 58
Joined: Thu Oct 28, 2010 1:56 pm

Re: Change text without changing language-files

Post by cangor » Wed Jan 10, 2018 10:02 am

Thanks for your reply.
david63 wrote:
Wed Jan 10, 2018 9:12 am
cangor wrote:
Wed Jan 10, 2018 8:57 am
but updating the extention would overwrite my changes
Npt sure what that means.
If I change the language-file of the extention and update the extention afterwards, the language-file will be replaced with the language-file of the update (replacing my changes as well).
Last edited by cangor on Wed Jan 10, 2018 10:05 am, edited 1 time in total.

cangor
Registered User
Posts: 58
Joined: Thu Oct 28, 2010 1:56 pm

Re: Change text without changing language-files

Post by cangor » Wed Jan 10, 2018 10:04 am

warmweer wrote:
Wed Jan 10, 2018 9:12 am
Your reasoning isn't logical in that respect because any update to the style would also overwrite the changes you made.
Not if it's an user-defined style. A style can be inherited from a parent style. For example I use "my style", inherited from prosilver, which only contains the changes I made to prosilver. This is very handy and it would be great if it worked with language-files too.

cangor
Registered User
Posts: 58
Joined: Thu Oct 28, 2010 1:56 pm

Re: Change text without changing language-files

Post by cangor » Wed Jan 10, 2018 10:57 am

kasimi wrote:
Wed Jan 10, 2018 9:32 am
As David already hinted at, you can put 'GALLERY' => 'My gallery of cars', in a language file of your own extension, use the same event where the Gallery extension loads that language file but with a lower priority so that your event is handled after (or basically any other event that is triggered at a later point but before the language key is used), and load your own language file there. This will make your language key overwrite the Gallery's one.
Thank you. It works using the events core.user_setup (with priority -1) or core.user_setup_after.

But it seems language-files have to be inside the /language/ folder or inside the extention's language-folder, there is no way to make it style-dependend. Am I right? It would be great to change the language according to the style, like:
'My car style' => "My car gallery"
'My garden style' => "My garden gallery"
etc.

User avatar
kasimi
Extension Customisations
Extension Customisations
Posts: 2760
Joined: Sat Sep 10, 2011 7:12 pm
Location: Germany
Contact:

Re: Change text without changing language-files

Post by kasimi » Wed Jan 10, 2018 11:15 am

The only way to do that is to include the car language file if the user is using the car style, include the garden language file if the user is using the garden style, and so on.

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

Re: Change text without changing language-files

Post by warmweer » Wed Jan 10, 2018 11:31 am

cangor wrote:
Wed Jan 10, 2018 10:04 am
warmweer wrote:
Wed Jan 10, 2018 9:12 am
Your reasoning isn't logical in that respect because any update to the style would also overwrite the changes you made.
Not if it's an user-defined style. A style can be inherited from a parent style. For example I use "my style", inherited from prosilver, which only contains the changes I made to prosilver. This is very handy and it would be great if it worked with language-files too.
OK, now I understand what you meant (and I take back my statement about it not being logical).
Still, even with user-defined styles you'll probably have to check whether if your user-defined changes are still applicable after the parent-style was updated (probably yes, but you never know).
A bug is a feature that hasn't made it to the manual (yet)

cangor
Registered User
Posts: 58
Joined: Thu Oct 28, 2010 1:56 pm

Re: Change text without changing language-files

Post by cangor » Wed Jan 10, 2018 1:03 pm

warmweer wrote:
Wed Jan 10, 2018 11:31 am
Still, even with user-defined styles you'll probably have to check whether if your user-defined changes are still applicable after the parent-style was updated (probably yes, but you never know).
You are right. Would be a good world if we run out of work :lol:

Post Reply

Return to “Extension Writers Discussion”

Who is online

Users browsing this forum: No registered users and 8 guests