News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Which version of the XML should I use?

Started by jsx, December 17, 2018, 11:38:39 AM

Previous topic - Next topic

jsx

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.

<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:

<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>

Arantor

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)

jsx

If I understood correctly, I must use the second code, right?


Arantor

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.

jsx

Thanks for the explanation. I do not need to use the file name install_polish-utf8.xml can be just polish-utf8.xml?

Arantor

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.

jsx

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.

Arantor

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.

jsx


jsx

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.

<?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.

<?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>

SychO

because in the first code you didn't tell the package manager to extract the file to $languagedir ?

<?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>
Checkout My Themes:
-

Potato  •  Ackerman  •  SunRise  •  NightBreeze

nour

Quote from: Arantor 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.

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.

Arantor

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.

jsx

@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?

<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:

<?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:

<?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>

SychO

I have no idea what it is you're trying to do exactly
Checkout My Themes:
-

Potato  •  Ackerman  •  SunRise  •  NightBreeze

jsx

Quote from: SychO on January 30, 2019, 01:10:36 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?

<?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?

<?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?

Arantor

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.

SychO

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()
Checkout My Themes:
-

Potato  •  Ackerman  •  SunRise  •  NightBreeze

jsx

In previous post I just gave an example.

This code will install the XML language file:

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


And this code will install the PHP language file:

<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?

Arantor

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.

Advertisement: