Skip to content
This repository was archived by the owner on May 3, 2024. It is now read-only.

Conversation

@ljacmi
Copy link

@ljacmi ljacmi commented Feb 7, 2024

No description provided.

@ljacmi ljacmi requested a review from iherak February 7, 2024 17:13
<a href="{{ url }}">{{ content_type.name }}</a>
{% set locale_conversion_map = ibexa.configResolver.getParameter('locale.conversion_map', 'ngsite') %}
{% for language in content.versionInfo.languages %}
&nbsp {{ locale_conversion_map[language.languageCode]|split('_')|last|nglayouts_country_flag|raw }}
Copy link
Member

@emodric emodric Feb 8, 2024

Choose a reason for hiding this comment

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

&nbsp (should be &nbsp; btw) is an error here I guess? Why not just separate languages with commas?

Also, don't use nglayouts_country_flag, this package cannot depend on Netgen Layouts. If needed, implement a custom Twig function to fetch the language name with LanguageService from Ibexa.

Copy link
Author

@ljacmi ljacmi Feb 8, 2024

Choose a reason for hiding this comment

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

Also, don't use nglayouts_country_flag, this package cannot depend on Netgen Layouts. If needed, implement a custom Twig function to fetch the language name with LanguageService from Ibexa.

Nije greška, komentar na povezanom tasku na fini glasi:
"pliz ne zaboravi dodat razmak između content tip linka i ovih zastavica. Na Fini je nabijeno"

Može se promijenit, al meni se i ovo čini ok

Copy link
Author

Choose a reason for hiding this comment

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

@emodric

Also, don't use nglayouts_country_flag, this package cannot depend on Netgen Layouts. If needed, implement a custom Twig function to fetch the language name with LanguageService from Ibexa.

@iherak suggested we put this in media-site instead of here. Your thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

That is project code, this is open source. This open source package cannot depend on Netgen Layouts. And since there will be no flags, there should be a comma separating the language names.

The alternative is to reimplement here the function to generate flags.

Copy link
Member

Choose a reason for hiding this comment

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

@iherak suggested we put this in media-site instead of here. Your thoughts?

Not ideal. Only new websites will then benefit from that unless we proactively implement it on older sites. Upgradablilty is also a problem. The template is not completely trivial, so any change here later will need to be propagated manually.

Copy link
Author

@ljacmi ljacmi Feb 8, 2024

Choose a reason for hiding this comment

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

@iherak suggested we put this in media-site instead of here. Your thoughts?

Not ideal. Only new websites will then benefit from that unless we proactively implement it on older sites. Upgradablilty is also a problem. The template is not completely trivial, so any change here later will need to be propagated manually.

@emodric Do you have a suggestion then?
EDIT: Reiplement the function?

Copy link
Member

Choose a reason for hiding this comment

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

My suggestion still stands. Just list the comma separated language names. Implement a Twig function to fetch the language by its language code and use the language object to fetch the name e.g. ngadmin_language('cro-HR').name

Copy link
Author

Choose a reason for hiding this comment

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

@emodric Is this ok now?

public function getFilters()
{
return [
new TwigFunction(
Copy link
Member

Choose a reason for hiding this comment

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

You're using a Twig function under filters. This should be moved to getFunctions.

{
return [
new TwigFunction(
'show_language_name',
Copy link
Member

Choose a reason for hiding this comment

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

This should be ngadmin_language so we can fetch the object instead of the name, which allows some more flexibility.

}

/**
* @throws NotFoundException
Copy link
Member

Choose a reason for hiding this comment

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

The method does not throw, so this is redundant.

{% for language in content.versionInfo.languages %}
{% set array = array|merge([language.languageCode|show_language_name]) %}
{% endfor %}
&nbsp {{array|join(', ') }}
Copy link
Member

Choose a reason for hiding this comment

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

&nbsp is not needed now.

Copy link
Author

@ljacmi ljacmi Feb 8, 2024

Choose a reason for hiding this comment

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

It is IMO.

Without:
image

With:
image

Copy link
Member

Choose a reason for hiding this comment

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

Why not add the list of languages below the content type name?

Besides, &nbsp should really be &nbsp; (with a semicolon).

Copy link
Author

Choose a reason for hiding this comment

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

Idk, flags were in the same row. It can be either way I guess: This is how it was done originally so I didn't change it.

@emodric
Copy link
Member

emodric commented Feb 8, 2024

Wait wait wait wait... It seems that content.versionInfo.languages is already a list of language objects, meaning you don't need the Twig function/filter after all 🤦‍♂️. You can just use language.name directly in the iteration! 🤣

@ljacmi
Copy link
Author

ljacmi commented Feb 8, 2024

Wait wait wait wait... It seems that content.versionInfo.languages is already a list of language objects, meaning you don't need the Twig function/filter after all 🤦‍♂️. You can just use language.name directly in the iteration! 🤣

Done

</a>
<a href="{{ url }}">{{ content_type.name }}</a>

{% set array = [] %}
Copy link
Member

Choose a reason for hiding this comment

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

One final nitpick, this variable should be named something like languages or language_names

Copy link
Author

Choose a reason for hiding this comment

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

Done

@emodric emodric requested a review from pspanja February 8, 2024 14:52
@emodric
Copy link
Member

emodric commented Feb 8, 2024

Thanks @ljacmi ! I will leave this to @pspanja to merge and release.

</a>
<a href="{{ url }}">{{ content_type.name }}</a>

{% set language_names = [] %}
Copy link
Member

Choose a reason for hiding this comment

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

Why is the logic within span if we are rendering this outside of the span? :)

Copy link
Author

Choose a reason for hiding this comment

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

Moved

@iherak iherak self-requested a review February 8, 2024 14:54
Copy link
Member

@pspanja pspanja left a comment

Choose a reason for hiding this comment

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

It seems I missed this. Thanks @ljacmi!

@pspanja pspanja merged commit 8a42221 into master May 3, 2024
@pspanja pspanja deleted the NGSTACK-829-add-translation-indication-below-object-name branch May 3, 2024 07:39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants