Advertisement:

Author Topic: Which version of the XML should I use?  (Read 1798 times)

Offline jsx

  • Jr. Member
  • **
  • Posts: 339
  • Gender: Male
Which version of the XML should I use?
« on: December 17, 2018, 11:38:39 AM »
Hey,

I created a translation for some modification and I would like to know which version of the XML code should I use in package-info? Both versions of the code are correct, because the translation will install correctly. But which version better to use? I am asking about it for the knowledge.

Code: [Select]
<install>
<modification format="xml" type="file">install_polish-utf8.xml</modification>
</install>

<uninstall>
<modification type="file" reverse="true">install_polish-utf8.xml</modification>
</uninstall>

Second version:

Code: [Select]
<install for="2.0 - 2.0.99">
<modification type="file">install_polish-utf8.xml</modification>
</install>

<uninstall for="2.0 - 2.0.99">
<modification type="file" reverse="true">install_polish-utf8.xml</modification>
</uninstall>

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 70,994
    • StoryBB/StoryBB on GitHub
Re: Which version of the XML should I use?
« Reply #1 on: December 17, 2018, 11:47:09 AM »
The latter as it covers the versions that should be installed against. If you need to do something different in 2.1 for example you can have a block of just 2.1 install instructions (the block you posted is just for 2.0)
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline jsx

  • Jr. Member
  • **
  • Posts: 339
  • Gender: Male
Re: Which version of the XML should I use?
« Reply #2 on: December 17, 2018, 01:03:34 PM »
If I understood correctly, I must use the second code, right?


Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 70,994
    • StoryBB/StoryBB on GitHub
Re: Which version of the XML should I use?
« Reply #3 on: December 17, 2018, 01:34:47 PM »
Both work, but the second is better because you can say which versions of SMF you want. The first will try to install on anything.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline jsx

  • Jr. Member
  • **
  • Posts: 339
  • Gender: Male
Re: Which version of the XML should I use?
« Reply #4 on: December 17, 2018, 02:13:59 PM »
Thanks for the explanation. I do not need to use the file name install_polish-utf8.xml can be just polish-utf8.xml?

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 70,994
    • StoryBB/StoryBB on GitHub
Re: Which version of the XML should I use?
« Reply #5 on: December 17, 2018, 02:28:24 PM »
As long as the file in the zip file is called the same as the XML points to, you can call it whatever you like.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline jsx

  • Jr. Member
  • **
  • Posts: 339
  • Gender: Male
Re: Which version of the XML should I use?
« Reply #6 on: December 17, 2018, 02:59:42 PM »
The name of the modification package is: Change All Subjects.zip
The name of the package with the translation is: Change_All_Subjects_PL.zip
The name of the file with the translation is: install_polish-utf8.xml or polish-utf8.xml

And the translation works fine.

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 70,994
    • StoryBB/StoryBB on GitHub
Re: Which version of the XML should I use?
« Reply #7 on: December 17, 2018, 03:08:37 PM »
i don’t know how I can explain this any other way.

You can call the file whatever you like. SMF does not care what filename you use at all. All it cares is that the package info file says to use a file, and that the file exists. Any name the file has is for human use only.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline jsx

  • Jr. Member
  • **
  • Posts: 339
  • Gender: Male
Re: Which version of the XML should I use?
« Reply #8 on: December 17, 2018, 03:58:42 PM »
All right, topic solved.

Offline jsx

  • Jr. Member
  • **
  • Posts: 339
  • Gender: Male
Re: Which version of the XML should I use?
« Reply #9 on: January 27, 2019, 01:22:01 PM »
I have a question again.

1. Why in this first installer I can install the translation for the modification that is in the XML file, and the PHP file will not be installed through this installer.

Example:

polish-utf8.xml - this translation will be installed correctly

Announcements.polish-utf8.php - this translation not will be installed correctly, occurs modification parsing error.

Code: [Select]
<?xml version="1.0"?>
<!DOCTYPE package-info SYSTEM "http://www.simplemachines.org/xml/package-info">
<package-info xmlns="http://www.simplemachines.org/xml/package-info" xmlns:smf="http://www.simplemachines.org/">
<name></name>
<id></id>
<version>1.0</version>
<type>modification</type>

<install for="2.0 - 2.0.99">
<modification type="file">polish-utf8.xml</modification>
</install>

<uninstall for="2.0 - 2.0.99">
<modification type="file" reverse="true">polish-utf8.xml</modification>
</uninstall>

</package-info>

2. Through this installer, the translation that is in the PHP file will install correctly.

Code: [Select]
<?xml version="1.0"?>
<!DOCTYPE package-info SYSTEM "http://www.simplemachines.org/xml/package-info">
<package-info xmlns="http://www.simplemachines.org/xml/package-info" xmlns:smf="http://www.simplemachines.org/">
   <name></name>
   <id></id>
   <type>modification</type>
   <version>1.0</version>
   <install>
      <require-file name="Announcements.polish-utf8.php" destination="$languagedir" />
   </install>
   
   <uninstall>
      <remove-file name="$languagedir/Announcements.polish-utf8.php" />
   </uninstall>
</package-info>

Online SychO

  • Lead Customizer
  • Sophist Member
  • *
  • Posts: 1,274
  • Gender: Male
    • SychO9 on GitHub
    • SychO
Re: Which version of the XML should I use?
« Reply #10 on: January 27, 2019, 01:46:39 PM »
because in the first code you didn't tell the package manager to extract the file to $languagedir ?

Code: [Select]
<?xml version="1.0"?>
<!DOCTYPE package-info SYSTEM "http://www.simplemachines.org/xml/package-info">
<package-info xmlns="http://www.simplemachines.org/xml/package-info" xmlns:smf="http://www.simplemachines.org/">
<name></name>
<id></id>
<version>1.0</version>
<type>modification</type>

<install for="2.0 - 2.0.99">
<modification type="file">polish-utf8.xml</modification>
<require-file name="Announcements.polish-utf8.php" destination="$languagedir" />
</install>

<uninstall for="2.0 - 2.0.99">
<modification type="file" reverse="true">polish-utf8.xml</modification>
<remove-file name="$languagedir/Announcements.polish-utf8.php" />
</uninstall>

</package-info>

Imazighen

Offline nour

  • Newbie
  • *
  • Posts: 2
Re: Which version of the XML should I use?
« Reply #11 on: January 29, 2019, 07:27:59 AM »
Both work, but the second is better because you can say which versions of SMF you want. The first will try to install on anything.

I totally agree,
But if youproject that your code is not version dependant, i.e. it works with all future versions than both codes become the same thing.

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 70,994
    • StoryBB/StoryBB on GitHub
Re: Which version of the XML should I use?
« Reply #12 on: January 29, 2019, 07:30:20 AM »
I hate to be that guy, but that is massively more complex than you can possibly imagine for anything non trivial in SMF’s world.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline jsx

  • Jr. Member
  • **
  • Posts: 339
  • Gender: Male
Re: Which version of the XML should I use?
« Reply #13 on: January 30, 2019, 07:02:58 AM »
@SychO

Thanks for clarification. But these lines can be removed from this code, because the only file with the translation is this file Announcements.polish-utf8.php. Right?

Code: [Select]
<modification type="file">polish-utf8.xml</modification>

<modification type="file" reverse="true">polish-utf8.xml</modification>

And if the translation was only in the file eg polish-utf8.xml, then only these lines must be in this installer, right?

Now everything is correct in these installers?

Installer for translation in a PHP file:

Code: [Select]
<?xml version="1.0"?>
<!DOCTYPE package-info SYSTEM "http://www.simplemachines.org/xml/package-info">
<package-info xmlns="http://www.simplemachines.org/xml/package-info" xmlns:smf="http://www.simplemachines.org/">
<name></name>
<id></id>
<version>1.0</version>
<type>modification</type>

<install for="2.0 - 2.0.99">
<require-file name="Announcements.polish-utf8.php" destination="$languagedir" />
</install>

<uninstall for="2.0 - 2.0.99">
<remove-file name="$languagedir/Announcements.polish-utf8.php" />
</uninstall>

</package-info>

Installer for translation in a XML file:

Code: [Select]
<?xml version="1.0"?>
<!DOCTYPE package-info SYSTEM "http://www.simplemachines.org/xml/package-info">
<package-info xmlns="http://www.simplemachines.org/xml/package-info" xmlns:smf="http://www.simplemachines.org/">
<name></name>
<id></id>
<version>1.0</version>
<type>modification</type>

<install for="2.0 - 2.0.99">
<modification type="file">polish-utf8.xml</modification>
</install>

<uninstall for="2.0 - 2.0.99">
<modification type="file" reverse="true">polish-utf8.xml</modification>

</uninstall>

</package-info>

Online SychO

  • Lead Customizer
  • Sophist Member
  • *
  • Posts: 1,274
  • Gender: Male
    • SychO9 on GitHub
    • SychO
Re: Which version of the XML should I use?
« Reply #14 on: January 30, 2019, 01:10:36 PM »
I have no idea what it is you're trying to do exactly

Imazighen

Offline jsx

  • Jr. Member
  • **
  • Posts: 339
  • Gender: Male
Re: Which version of the XML should I use?
« Reply #15 on: February 10, 2019, 02:37:15 PM »
I have no idea what it is you're trying to do exactly

There are such modifications SMF that contain a language file in XML. So, which should I use the installer to install the translation that is contained in the XML file?

This?

Code: [Select]
<?xml version="1.0"?>
<!DOCTYPE package-info SYSTEM "http://www.simplemachines.org/xml/package-info">
<package-info xmlns="http://www.simplemachines.org/xml/package-info" xmlns:smf="http://www.simplemachines.org/">
<name></name>
<id></id>
<version>1.0</version>
<type>modification</type>

<install for="2.0 - 2.0.99">
<modification type="file">polish-utf8.xml</modification>
</install>

<uninstall for="2.0 - 2.0.99">
<modification type="file" reverse="true">polish-utf8.xml</modification>

</uninstall>

</package-info>

Or this one?

Code: [Select]
<?xml version="1.0"?>
<!DOCTYPE package-info SYSTEM "http://www.simplemachines.org/xml/package-info">
<package-info xmlns="http://www.simplemachines.org/xml/package-info" xmlns:smf="http://www.simplemachines.org/">
<name></name>
<id></id>
<version>1.0</version>
<type>modification</type>

<install for="2.0 - 2.0.99">
<require-file name="polish-utf8.xml" destination="$languagedir" />
</install>

<uninstall for="2.0 - 2.0.99">
<remove-file name="$languagedir/polish-utf8.xml" />
</uninstall>

</package-info>

And there are such modifications SMF that contain a language file in PHP. So, which should I use the installer to install the translation that is contained in the PHP file? The first or the second code?

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 70,994
    • StoryBB/StoryBB on GitHub
Re: Which version of the XML should I use?
« Reply #16 on: February 10, 2019, 02:57:39 PM »
You have confused yourself entirely with this. The second one doesn’t work because you’re not including language files, you’re trying to include an XML file in to the languages areas, which SMF will ignore.

Adding a whole new file is cleaner but it requires you use loadLanguage() in your code to load the right thing.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Online SychO

  • Lead Customizer
  • Sophist Member
  • *
  • Posts: 1,274
  • Gender: Male
    • SychO9 on GitHub
    • SychO
Re: Which version of the XML should I use?
« Reply #17 on: February 10, 2019, 03:03:27 PM »
In addition to what Arantor said,

If you use the first one, you can just add new text strings to Modifications.{lang}.php, as long as you know the right syntax. And you won't have to use loadLanguage()

Imazighen

Offline jsx

  • Jr. Member
  • **
  • Posts: 339
  • Gender: Male
Re: Which version of the XML should I use?
« Reply #18 on: February 10, 2019, 04:26:37 PM »
In previous post I just gave an example.

This code will install the XML language file:

Code: [Select]
<install for="2.0 - 2.0.99">
<modification type="file">polish-utf8.xml</modification>
</install>

And this code will install the PHP language file:

Code: [Select]
<install for="2.0 - 2.0.99">
<require-file name="...polish-utf8.php" destination="$languagedir" />
</install>

I have one more question. Why is the content of the translation that is in the PHP file that was installed by the package is not located in the Modifications.polish-utf8.php file?

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 70,994
    • StoryBB/StoryBB on GitHub
Re: Which version of the XML should I use?
« Reply #19 on: February 10, 2019, 04:46:09 PM »
Because you didn't tell it to? The package manager follows your instructions literally.

If you tell it to put a file into a folder, it's going to put a file into a folder. It doesn't know what the file is, it assumes that you know what you're doing.

If you want to edit Modifications-polish-utf8.php, write an XML file with search/add and use modification to include it.

If you want to add a completely new file, just include it and call loadLanguage() - if you have a lot of strings, better to do that than to clutter up Modifications, especially if you're adding a lot of stuff in a new section and you don't need to modify any files that way.


I'm honestly confused what is so difficult about this.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline jsx

  • Jr. Member
  • **
  • Posts: 339
  • Gender: Male
Re: Which version of the XML should I use?
« Reply #20 on: February 11, 2019, 04:03:14 AM »
If I understand this correctly, the content of the translation that is in the PHP file does not go to the Modifications.polish-utf8.php file because is in the own file.

Example:

../languages/OharaYTEmbed.polish-utf8.php

Thank you for your patience. :)

Online SychO

  • Lead Customizer
  • Sophist Member
  • *
  • Posts: 1,274
  • Gender: Male
    • SychO9 on GitHub
    • SychO
Re: Which version of the XML should I use?
« Reply #21 on: February 11, 2019, 04:44:03 AM »
no, that's not why

the file is added to the languages directory because you tell the package manager to do so
new language strings are added to Modifications.{lang}.php or any other language file, because you tell the package manager to execute a modification that does that work

you really need to read these
Package SDK: package-info.xml
Package SDK: modification.xml

Imazighen

Offline Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 58,241
  • Gender: Male
    • Kindred-999 on GitHub
Re: Which version of the XML should I use?
« Reply #22 on: February 11, 2019, 05:08:14 PM »
basically, I follow this rule of thumb.

If my mod adds under 20 text strings, I add those strings to the end of the modifications.language.php file....   if I'm going to add more, then I add my own separate file of strings just for the mod.


but doing that is two different commands in the mod install xml
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.