Jump to content

Translatable File and Image Descriptions


Recommended Posts

I have the same wish. But this is a little more complex than it sounds, so has to wait until there's time to do it right. However, shorter term the intention is that one can use an image field in a repeater to achieve something similar.

  • Like 1
Link to comment
Share on other sites

  • 9 months later...

Anything new about the multilanguage image description?

As i try to avoid that the site editor has the possibility to insert images in a texarea field, it's just a minor problem. For the most cases i will use a repeater field as ryan described. Just would be great to know for a current development site if there will be such a release soon or if it will take some more time to have this supported.

Link to comment
Share on other sites

  • 2 months later...

Greetings Everyone!

Hope it's ok to post in an old thread. 

I need the image description translation very much.

I was reading through the PHP internationalization page. In the last section it provides an example of how it is possible to translate dynamic strings...

$title = __($title, '/wire/templates-admin/default.php'); 

to translate the same field in many languages(Thats what I understood, correct me if I am wrong). So I tried to do something like this...

//  site/templates/album.php

<?php

$album_title = $page->title;

echo '<h1>'. __($album_title) .'</h1>';

$images = $page->images;
foreach($images as $image){
	$description = $image->description;
	$img_title = $image->name;
	echo '<div class="block"><a href="'. $image->url . '">'.
	'<img src="' . $image->width(190)->url . '" />';
	echo '<h3>' . __($img_title) . '</h3>'.'<p>';
	echo __($description);
	echo '</p></a></div>';
}

and tried to add album.php to translate in admin > setup > language > ru (that should create the json file to store the translations in there...). 

But the admin panel says that "That file has no translatable phrases". 

I guess I misunderstood about passing a dynamic string to the __() function. So there goes the questions.

1. Is this possible to achieve?

2. Whats wrong with my approach?

3. What is the right way and right scenarios allow me to pass a dynamic string to the __() function?

Please Help

Link to comment
Share on other sites

You can only pass static strings to the __() function. At least, the translation parser will only be able to find static strings. The only reason you'd put a variable in a call to the __() function, is if you knew the text was already available translated, and wanted to retrieve the translated version. But that text would have had to appear statically, somewhere else in the file. 

To make a multi-langage image field, you can use a Repeater. Your repeater would contain two fields: 'image' and 'summary'. Make the 'image' field of type Image, and set to to contain max 1 image. Make the 'summary' field of type TextLanguage (or TextareaLanguage). 

The Image field is the next one on the list to make multi-language capable, so should be within the next major version of ProcessWire. 

  • Like 6
Link to comment
Share on other sites

Thank you a lot Ryan. I get it now.

I was aware about the repeater but I did not like the idea of uploading bunch of images one by one. If I am not wrong thats what's going to happen, however I did not try it yet.

Anyway I will find out tomorrow, it seems that I don't have any other choice. Thank you for including this feature for the future updates. 

Sorry for bothering you with silly questions at first time.

Link to comment
Share on other sites

  • 11 months later...

You can only pass static strings to the __() function. At least, the translation parser will only be able to find static strings. The only reason you'd put a variable in a call to the __() function, is if you knew the text was already available translated, and wanted to retrieve the translated version. But that text would have had to appear statically, somewhere else in the file. 

To make a multi-langage image field, you can use a Repeater. Your repeater would contain two fields: 'image' and 'summary'. Make the 'image' field of type Image, and set to to contain max 1 image. Make the 'summary' field of type TextLanguage (or TextareaLanguage). 

The Image field is the next one on the list to make multi-language capable, so should be within the next major version of ProcessWire. 

Oh I've found the best thread for my problem, so I'm asking if you have plans to implement the image field translation thing to the next release? :)

  • Like 1
Link to comment
Share on other sites

The Image field is the next one on the list to make multi-language capable, so should be within the next major version of ProcessWire.

@ryan

since I am quite happy with PW 2.4 I kindly ask if there is any progress for the multi-language-image-description-field?

I tried to make it by myself but it goes too deep in the sourcecode so that I decided to keep my hands off.

  • Like 1
Link to comment
Share on other sites

  • 2 months later...

File and image fields now support multiple languages for the description (in the current PW dev branch). The multi-language capability was built directly in the existing file/image fields, so nothing needs to be installed/modified–they simply become multi-language when you've got language support active. 

Thanks to stardesign for sponsoring this addition. 

  • Like 16
Link to comment
Share on other sites

  • 4 months later...

hey hope i am not too late..

is there any possibility that following error will be available for translation ?

in wire\modules\inputfield\inputfieldfile\inputfieldfile.js

$fileList.append(errorItem(files[i].name, extension + ' is a invalid file extension, please use one of:  ' + extensions));
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...