Hurme Posted September 24, 2018 Share Posted September 24, 2018 Hi, I was making a multi language site with download section that would automatically list files based on language. I was going to check if $file->description had any content on current language, but this does not work as it always returns the default language even when different language is selected. Example: Site has three languages, english (default), french and german. document_en.pdf | en desc "lorem ipsum" | fr desc "" | de desc "" document_fr.pdf | en desc "" | fr desc "lorem ipsum" | de desc "" document_de.pdf | en desc "" | fr desc "" | de desc "lorem ipsum" It would iterate through all of these and only return the documents that had description in current language. Problem is it will always return document_en.pdf no matter which language is selected. For french and german it correctly only shows them according to the language. Currently using PW version 3.0.95. Link to comment Share on other sites More sharing options...
AndZyk Posted September 24, 2018 Share Posted September 24, 2018 Hi @Hurme, this would be an ideal use case for language-alternate fields, if you haven‘t heard of them.? Or if you dont‘ want to use them, you could try to disable, that if no translation exists, the default language will be used. But language-alternate fields would be better. Regards, Andreas 2 1 Link to comment Share on other sites More sharing options...
Hurme Posted September 25, 2018 Author Share Posted September 25, 2018 Hi, I solved the issue by making using the tags option in the files field and by disabling the multi language description altogether. I had read about the language-alternate fields, but had forgotten about them by the time I was doing this site. So cheers for the reminder. ? I still think the file fields description is behaving in a not so logical way. Luckily it's a problem you can easily get around in multiple ways. Link to comment Share on other sites More sharing options...
LostKobrakai Posted September 30, 2018 Share Posted September 30, 2018 https://processwire.com/api/ref/pagefile/description/ See the last example on how to get the description in a specific language. 2 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now