Nested Translation with RecordDataFormatter

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Nested Translation with RecordDataFormatter

Beck, Julia

Dear VuFinders,

 

this week I upgraded from VuFind 2.5 to VuFind 4.0 on our testserver and ran into a problem while trying out the new RecordDataFormatter(Factory).

Background: For our language field we use iso639-1, but as we don’t have MARC data, we do not make use of the translation_maps of the SolrMarc Importer. Instead we have translation files. The file structure is nested:

local > languages > iso639-1 > de.ini, en.ini, …

Before the RecordDataFormatter, we just used transEsc(‘iso639-1::’ . $lang) in the core template of our module.

 

Now I try to understand how to make this work with the RecordDataFormatterFactory. I thought a line like

$spec->setLine(‘Language’,’getLanguages’,’Simple’,[‘prefix’ => ‘iso639-1::’,’translate’ => true])

would do the trick, but that produces the output “iso639-1::en” and not “English” (as the renderSimple() functions adds the prefix after translating as far as I understand).

When I look at the other examples in the Factory with “CreatorRoles::”, I assume it should work similarly. Maybe I need to use setTemplateLine() instead to translate it later on in a custom template? I think did not really get the difference between setline() and setTemplateLine() yet.

 

Julia

 

--

Julia Beck

Fachinformationsdienst Darstellende Kunst

http://performing-arts.eu

 

Universitätsbibliothek Johann Christian Senckenberg

Elektronische Dienste

Bockenheimer Landstrasse 134-138

D - 60325 Frankfurt am Main

[hidden email]

+49 69 798-39387

 


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Vufind-tech mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/vufind-tech
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Nested Translation with RecordDataFormatter

Demian Katz

Julia,

 

As you say, the ‘prefix’ setting used by the ‘Simple’ render mode is designed to contain an HTML fragment, not a translation text domain. The ‘prefix’ setting that contains ‘CreatorRoles::’ elsewhere in the example factory is being passed as a template variable. Apologies for the confusion caused by using the same key in two totally different contexts.

 

It would probably make sense to add a new config option called ‘translationTextDomain’ to the ‘Simple’ render mode to support your use case. If that would be helpful, I can look into doing that as a new feature in release 4.1 (or you could submit a pull request, if you have the necessary time and interest). In the meantime, though, as you say, the easiest thing is probably to accomplish this with a custom template.

 

As for the difference between setLine and setTemplateLine, you can do everything through setLine directly – but setTemplateLine offers a more convenient parameter list when you are creating a line that renders a template.

 

I hope this is helpful. Please let me know if you would like more help!

 

- Demian

 

From: Beck, Julia [mailto:[hidden email]]
Sent: Wednesday, July 19, 2017 12:53 PM
To: [hidden email]
Subject: [VuFind-Tech] Nested Translation with RecordDataFormatter

 

Dear VuFinders,

 

this week I upgraded from VuFind 2.5 to VuFind 4.0 on our testserver and ran into a problem while trying out the new RecordDataFormatter(Factory).

Background: For our language field we use iso639-1, but as we don’t have MARC data, we do not make use of the translation_maps of the SolrMarc Importer. Instead we have translation files. The file structure is nested:

local > languages > iso639-1 > de.ini, en.ini, …

Before the RecordDataFormatter, we just used transEsc(‘iso639-1::’ . $lang) in the core template of our module.

 

Now I try to understand how to make this work with the RecordDataFormatterFactory. I thought a line like

$spec->setLine(‘Language’,’getLanguages’,’Simple’,[‘prefix’ => ‘iso639-1::’,’translate’ => true])

would do the trick, but that produces the output “iso639-1::en” and not “English” (as the renderSimple() functions adds the prefix after translating as far as I understand).

When I look at the other examples in the Factory with “CreatorRoles::”, I assume it should work similarly. Maybe I need to use setTemplateLine() instead to translate it later on in a custom template? I think did not really get the difference between setline() and setTemplateLine() yet.

 

Julia

 

--

Julia Beck

Fachinformationsdienst Darstellende Kunst

http://performing-arts.eu

 

Universitätsbibliothek Johann Christian Senckenberg

Elektronische Dienste

Bockenheimer Landstrasse 134-138

D - 60325 Frankfurt am Main

[hidden email]

+49 69 798-39387

 


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Vufind-tech mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/vufind-tech
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Nested Translation with RecordDataFormatter

Beck, Julia

Sorry, the link was wrong. This is the pull request: https://github.com/vufind-org/vufind/pull/1009

 

Julia

 

Von: Beck, Julia
Gesendet: Donnerstag, 20. Juli 2017 11:21
An: 'Demian Katz'; [hidden email]
Betreff: AW: Nested Translation with RecordDataFormatter

 

Thanks for the explanation Demian. Now I get it.

 

I made a pull request https://sourceforge.net/p/vufind/mailman/message/35954280/ with a simple adjustment (it’s actually just 3 lines of code) that worked for me but you might want to check if there is more adjustment needed anywhere else in the code that I did not think of.

 

Julia

 

Von: Demian Katz [[hidden email]]
Gesendet: Mittwoch, 19. Juli 2017 19:20
An: Beck, Julia; [hidden email]
Betreff: RE: Nested Translation with RecordDataFormatter

 

Julia,

 

As you say, the ‘prefix’ setting used by the ‘Simple’ render mode is designed to contain an HTML fragment, not a translation text domain. The ‘prefix’ setting that contains ‘CreatorRoles::’ elsewhere in the example factory is being passed as a template variable. Apologies for the confusion caused by using the same key in two totally different contexts.

 

It would probably make sense to add a new config option called ‘translationTextDomain’ to the ‘Simple’ render mode to support your use case. If that would be helpful, I can look into doing that as a new feature in release 4.1 (or you could submit a pull request, if you have the necessary time and interest). In the meantime, though, as you say, the easiest thing is probably to accomplish this with a custom template.

 

As for the difference between setLine and setTemplateLine, you can do everything through setLine directly – but setTemplateLine offers a more convenient parameter list when you are creating a line that renders a template.

 

I hope this is helpful. Please let me know if you would like more help!

 

- Demian

 

From: Beck, Julia [[hidden email]]
Sent: Wednesday, July 19, 2017 12:53 PM
To: [hidden email]
Subject: [VuFind-Tech] Nested Translation with RecordDataFormatter

 

Dear VuFinders,

 

this week I upgraded from VuFind 2.5 to VuFind 4.0 on our testserver and ran into a problem while trying out the new RecordDataFormatter(Factory).

Background: For our language field we use iso639-1, but as we don’t have MARC data, we do not make use of the translation_maps of the SolrMarc Importer. Instead we have translation files. The file structure is nested:

local > languages > iso639-1 > de.ini, en.ini, …

Before the RecordDataFormatter, we just used transEsc(‘iso639-1::’ . $lang) in the core template of our module.

 

Now I try to understand how to make this work with the RecordDataFormatterFactory. I thought a line like

$spec->setLine(‘Language’,’getLanguages’,’Simple’,[‘prefix’ => ‘iso639-1::’,’translate’ => true])

would do the trick, but that produces the output “iso639-1::en” and not “English” (as the renderSimple() functions adds the prefix after translating as far as I understand).

When I look at the other examples in the Factory with “CreatorRoles::”, I assume it should work similarly. Maybe I need to use setTemplateLine() instead to translate it later on in a custom template? I think did not really get the difference between setline() and setTemplateLine() yet.

 

Julia

 

--

Julia Beck

Fachinformationsdienst Darstellende Kunst

MailScanner hat einen möglichen Täuschungsversuch durch "na01.safelinks.protection.outlook.com" festgestellt. http://performing-arts.eu

 

Universitätsbibliothek Johann Christian Senckenberg

Elektronische Dienste

Bockenheimer Landstrasse 134-138

D - 60325 Frankfurt am Main

[hidden email]

+49 69 798-39387

 


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Vufind-tech mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/vufind-tech
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Nested Translation with RecordDataFormatter

Beck, Julia
In reply to this post by Demian Katz

Thanks for the explanation Demian. Now I get it.

 

I made a pull request https://sourceforge.net/p/vufind/mailman/message/35954280/ with a simple adjustment (it’s actually just 3 lines of code) that worked for me but you might want to check if there is more adjustment needed anywhere else in the code that I did not think of.

 

Julia

 

Von: Demian Katz [mailto:[hidden email]]
Gesendet: Mittwoch, 19. Juli 2017 19:20
An: Beck, Julia; [hidden email]
Betreff: RE: Nested Translation with RecordDataFormatter

 

Julia,

 

As you say, the ‘prefix’ setting used by the ‘Simple’ render mode is designed to contain an HTML fragment, not a translation text domain. The ‘prefix’ setting that contains ‘CreatorRoles::’ elsewhere in the example factory is being passed as a template variable. Apologies for the confusion caused by using the same key in two totally different contexts.

 

It would probably make sense to add a new config option called ‘translationTextDomain’ to the ‘Simple’ render mode to support your use case. If that would be helpful, I can look into doing that as a new feature in release 4.1 (or you could submit a pull request, if you have the necessary time and interest). In the meantime, though, as you say, the easiest thing is probably to accomplish this with a custom template.

 

As for the difference between setLine and setTemplateLine, you can do everything through setLine directly – but setTemplateLine offers a more convenient parameter list when you are creating a line that renders a template.

 

I hope this is helpful. Please let me know if you would like more help!

 

- Demian

 

From: Beck, Julia [[hidden email]]
Sent: Wednesday, July 19, 2017 12:53 PM
To: [hidden email]
Subject: [VuFind-Tech] Nested Translation with RecordDataFormatter

 

Dear VuFinders,

 

this week I upgraded from VuFind 2.5 to VuFind 4.0 on our testserver and ran into a problem while trying out the new RecordDataFormatter(Factory).

Background: For our language field we use iso639-1, but as we don’t have MARC data, we do not make use of the translation_maps of the SolrMarc Importer. Instead we have translation files. The file structure is nested:

local > languages > iso639-1 > de.ini, en.ini, …

Before the RecordDataFormatter, we just used transEsc(‘iso639-1::’ . $lang) in the core template of our module.

 

Now I try to understand how to make this work with the RecordDataFormatterFactory. I thought a line like

$spec->setLine(‘Language’,’getLanguages’,’Simple’,[‘prefix’ => ‘iso639-1::’,’translate’ => true])

would do the trick, but that produces the output “iso639-1::en” and not “English” (as the renderSimple() functions adds the prefix after translating as far as I understand).

When I look at the other examples in the Factory with “CreatorRoles::”, I assume it should work similarly. Maybe I need to use setTemplateLine() instead to translate it later on in a custom template? I think did not really get the difference between setline() and setTemplateLine() yet.

 

Julia

 

--

Julia Beck

Fachinformationsdienst Darstellende Kunst

MailScanner hat einen möglichen Täuschungsversuch durch "na01.safelinks.protection.outlook.com" festgestellt. http://performing-arts.eu

 

Universitätsbibliothek Johann Christian Senckenberg

Elektronische Dienste

Bockenheimer Landstrasse 134-138

D - 60325 Frankfurt am Main

[hidden email]

+49 69 798-39387

 


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Vufind-tech mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/vufind-tech
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Nested Translation with RecordDataFormatter

Demian Katz

Thanks, Julia! I will review the code in the near future and either merge it or leave further comments on the PR. I appreciate the contribution!

 

- Demian

 

From: Beck, Julia [mailto:[hidden email]]
Sent: Thursday, July 20, 2017 5:21 AM
To: Demian Katz; [hidden email]
Subject: AW: Nested Translation with RecordDataFormatter

 

Thanks for the explanation Demian. Now I get it.

 

I made a pull request https://sourceforge.net/p/vufind/mailman/message/35954280/ with a simple adjustment (it’s actually just 3 lines of code) that worked for me but you might want to check if there is more adjustment needed anywhere else in the code that I did not think of.

 

Julia

 

Von: Demian Katz [[hidden email]]
Gesendet: Mittwoch, 19. Juli 2017 19:20
An: Beck, Julia; [hidden email]
Betreff: RE: Nested Translation with RecordDataFormatter

 

Julia,

 

As you say, the ‘prefix’ setting used by the ‘Simple’ render mode is designed to contain an HTML fragment, not a translation text domain. The ‘prefix’ setting that contains ‘CreatorRoles::’ elsewhere in the example factory is being passed as a template variable. Apologies for the confusion caused by using the same key in two totally different contexts.

 

It would probably make sense to add a new config option called ‘translationTextDomain’ to the ‘Simple’ render mode to support your use case. If that would be helpful, I can look into doing that as a new feature in release 4.1 (or you could submit a pull request, if you have the necessary time and interest). In the meantime, though, as you say, the easiest thing is probably to accomplish this with a custom template.

 

As for the difference between setLine and setTemplateLine, you can do everything through setLine directly – but setTemplateLine offers a more convenient parameter list when you are creating a line that renders a template.

 

I hope this is helpful. Please let me know if you would like more help!

 

- Demian

 

From: Beck, Julia [[hidden email]]
Sent: Wednesday, July 19, 2017 12:53 PM
To: [hidden email]
Subject: [VuFind-Tech] Nested Translation with RecordDataFormatter

 

Dear VuFinders,

 

this week I upgraded from VuFind 2.5 to VuFind 4.0 on our testserver and ran into a problem while trying out the new RecordDataFormatter(Factory).

Background: For our language field we use iso639-1, but as we don’t have MARC data, we do not make use of the translation_maps of the SolrMarc Importer. Instead we have translation files. The file structure is nested:

local > languages > iso639-1 > de.ini, en.ini, …

Before the RecordDataFormatter, we just used transEsc(‘iso639-1::’ . $lang) in the core template of our module.

 

Now I try to understand how to make this work with the RecordDataFormatterFactory. I thought a line like

$spec->setLine(‘Language’,’getLanguages’,’Simple’,[‘prefix’ => ‘iso639-1::’,’translate’ => true])

would do the trick, but that produces the output “iso639-1::en” and not “English” (as the renderSimple() functions adds the prefix after translating as far as I understand).

When I look at the other examples in the Factory with “CreatorRoles::”, I assume it should work similarly. Maybe I need to use setTemplateLine() instead to translate it later on in a custom template? I think did not really get the difference between setline() and setTemplateLine() yet.

 

Julia

 

--

Julia Beck

Fachinformationsdienst Darstellende Kunst

MailScanner hat einen möglichen Täuschungsversuch durch "na01.safelinks.protection.outlook.com" festgestellt. http://performing-arts.eu

 

Universitätsbibliothek Johann Christian Senckenberg

Elektronische Dienste

Bockenheimer Landstrasse 134-138

D - 60325 Frankfurt am Main

[hidden email]

+49 69 798-39387

 


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Vufind-tech mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/vufind-tech
Loading...