Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] New ViewHelper which gets all translations from a certain language file #746

Merged
merged 1 commit into from
Jan 6, 2015

Conversation

cbopp-art
Copy link
Contributor

This is a new ViewHelper which reads a language file and returns all the translations from.
A specific language key (e.g. 'de') can be defined to forces getting all translation from a different language instead of the current browsing language.
Furthermore, this viewhelper provides the argument jsonEncode for returning all the translations as a JSON object instead of an array. This may could be useful if the translations need to be used in frontend (client side).
Of course, there is already a separate Format/Json ViewHelper available. But in my opinion, it is more inconvenient for integrators to wrap this viewhelper tag once more just for reformating as well as it is worse from the performance side of view.

@@ -0,0 +1,143 @@
<?php
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

End of line character is invalid; expected "\n" but found "\r\n"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

End of line character is invalid; expected "\n" but found "\r\n"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

End of line character is invalid; expected "\n" but found "\r\n"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

End of line character is invalid; expected "\n" but found "\r\n"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

End of line character is invalid; expected "\n" but found "\r\n"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

End of line character is invalid; expected "\n" but found "\r\n"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

End of line character is invalid; expected "\n" but found "\r\n"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

End of line character is invalid; expected "\n" but found "\r\n"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

End of line character is invalid; expected "\n" but found "\r\n"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

End of line character is invalid; expected "\n" but found "\r\n"

@cbopp-art cbopp-art changed the title New language viewhelper for reading a full language file [FEATURE] New language viewhelper for reading a full language file Jan 3, 2015
@@ -0,0 +1,142 @@
<?php
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File has mixed line endings; this may cause incorrect results

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

End of line character is invalid; expected "\n" but found "\r\n"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File has mixed line endings; this may cause incorrect results

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

End of line character is invalid; expected "\n" but found "\r\n"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File has mixed line endings; this may cause incorrect results

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

End of line character is invalid; expected "\n" but found "\r\n"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File has mixed line endings; this may cause incorrect results

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

End of line character is invalid; expected "\n" but found "\r\n"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File has mixed line endings; this may cause incorrect results

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

End of line character is invalid; expected "\n" but found "\r\n"

@cedricziel
Copy link
Member

Please squash it together

@cbopp-art cbopp-art force-pushed the development branch 8 times, most recently from abc953a to 7fd1d2d Compare January 4, 2015 10:52
@cbopp-art cbopp-art changed the title [FEATURE] New language viewhelper for reading a full language file [FEATURE] New ViewHelper which gets all translations from a certain language file Jan 4, 2015
@cbopp-art cbopp-art force-pushed the development branch 3 times, most recently from 2182cc1 to f447aae Compare January 4, 2015 12:48
@NamelessCoder
Copy link
Member

This is an automated comment based on an automated formal commit review.

Your pull request contains formal errors. Comments have been assigned to each commit in your pull request - please review and adjust. Feel free to ask for help if you need it!

* @return string
*/
protected function resolvePath($path) {
if (FALSE === @is_file(GeneralUtility::getFileAbsFileName($path))) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Silencing errors is discouraged

@NamelessCoder
Copy link
Member

This is an automated comment based on an automated formal commit review.

Your pull request contains formal errors. Comments have been assigned to each commit in your pull request - please review and adjust. Feel free to ask for help if you need it!

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.27%) when pulling 6f4f415 on cbopp-art:development into feec8a1 on FluidTYPO3:development.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.27%) when pulling 6f4f415 on cbopp-art:development into feec8a1 on FluidTYPO3:development.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.27%) when pulling fdabe5e on cbopp-art:development into feec8a1 on FluidTYPO3:development.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.27%) when pulling 3a322f9 on cbopp-art:development into feec8a1 on FluidTYPO3:development.

* @param string $path
* @return string
*/
protected function resolvePath($path) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change to method body:

        $path = $this->arguments['path'];
        $absoluteFileName = GeneralUtility::getFileAbsFileName($path);
        if (FALSE === file_exists($absoluteFileName)) {
            $extensionName = $this->resolveExtensionName($this->arguments['extensionName']);
            $extensionKey = GeneralUtility::camelCaseToLowerCaseUnderscored($extensionName);
            $absoluteFileName = ExtensionManagementUtility::extPath($extensionKey, $path);
        }
        return $absoluteFileName;

And removing the $path function argument, to make it homogenous with resolveExtensionName.

Don't forget to import ExtensionManagementUtility.

@NamelessCoder
Copy link
Member

Last batch of fixes and we're there! Meticulously reviewed to make sure you only need one more round of changes - when fixed, merging is approved (if anyone else from the team is reading this and sees the update before I do).

Thanks again Cornel. Good stuff!

@xf-
Copy link
Contributor

xf- commented Jan 5, 2015

Maybe use a proper editor and install editorconfig support. errors like whitespace at end of lines, line breaks, newline will go away.

Editors supported http://editorconfig.org/#download

@cbopp-art
Copy link
Contributor Author

@xf-
Basically I'm using phpstorm 7.1. But I had big performance issues since last time so that I needed to use an alternative editor.

@xf-
Copy link
Contributor

xf- commented Jan 5, 2015

@cbopp-art v8 is out

@cbopp-art cbopp-art force-pushed the development branch 2 times, most recently from bc29a83 to b20b1b8 Compare January 5, 2015 21:56
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.29%) when pulling b20b1b8 on cbopp-art:development into feec8a1 on FluidTYPO3:development.

@cbopp-art
Copy link
Contributor Author

@NamelessCoder
Thanks for the review! The changes have been made.
What's about documentation of new viewhelpers? Do I need to do something further then (e.g. fluidtypo3.org)?

* @subpackage ViewHelpers\Resource
*/

use \FluidTYPO3\Vhs\Utility\ViewHelperUtility;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed this earlier, sorry! The class comment and the comment above the "use" statements are duplicates - the comment above should be used as class comment and the current class comment removed. And of course the "use" statements should then be moved above the class doc comment.

This will also take care of the documentation perspective. EXT:schemaker will use this documentation block when VHS docs are regenerated.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.29%) when pulling 3665ef0 on cbopp-art:development into 146126d on FluidTYPO3:development.

@NamelessCoder
Copy link
Member

Right on! :)

NamelessCoder added a commit that referenced this pull request Jan 6, 2015
[FEATURE] New ViewHelper which gets all translations from a certain language file
@NamelessCoder NamelessCoder merged commit a51b62f into FluidTYPO3:development Jan 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants