How can i search where it is used liferay default language property? - properties

I want to change Liferay default language property, but i dont know in what places it uses.
I find a full list of liferay properties here Language_eu.properties
I used a hook to change a default value, imagine i want to change this key:
to= [toInEuLanguage]
But i dont know full context of all cases liferay it uses this key.
Imagine i put that on the key:
to= -
And liferay use it on this case:
Correct:
15 to 20 results
EU: 15 - 20 results_eu
But maybe liferay it uses on other case like this (not real case):
Incorrect:
Time to leave
EU: Time_eu - leave_eu
Exactly want to change a literal used on liferay default pagination.
I used liferay pagination on a template, and by default administration of liferay uses it too.
Is there a way to check where liferay use a particular key and the context of it?

I'm afraid it is next to impossible to find all the places a key is used. Anything (portlet, servlet, service, jsp page, template, theme, ...) can request any key at any time. There is nothing that keeps track of what uses what key.
I'm not sure why you want to change the default but that is usually not a good idea. If something is wrongly translated or should be changed globally, the best way is to use https://crowdin.com/project/liferay-portal and get in touch with proofreaders for the given language.
If you want to customize existing application, then you should look how that is used in that particular application. It may be the same challenge but the scope is much much narrower.
If you only want to make use of the key in your application then the best option is to have own properties.

Related

Shopware 6 add entity extension fields to admin search

I wonder how to make some fields of an entity extension searchable in the administration through the "/api/search/my-entity" api-endpoint. By default they are not considered during search as it looks like.
I found the answer by debugging the search-endpoint:
The association-Field of the EntityExtension needs to have a SearchRanking-flag:
...->addFlags(new SearchRanking(SearchRanking::ASSOCIATION_SEARCH_RANKING))
Then you can add SearchRanking-flags in the EntityExtensionDefinition as you like, e.g.:
(new StringField('test', 'test'))->addFlags(new SearchRanking(SearchRanking::HIGH_SEARCH_RANKING)),
After that the fields are searchable via the search-endpoint :)
As far as the API is concerned, search functionality should automatically be generated following your custom entity definitions.
When it comes to facilitate Admin search for your entity, you need to add some code to the administration component as described in the docs: https://developer.shopware.com/docs/guides/plugins/plugins/administration/search-custom-data (even though it looks not fully up-to-date w.r.t to the current Shopware versions).

In IdentityServer4, how do you securely store the ReturnUrl?

I am developing an identity server 4 dotnet core application so this is as much as a dotnet question than and IDS4 question. One example of state I need to maintain between pages (login, signup etc...) is the returnUrl. The application I'm migrating from used to store it in a session variable but, as I understand, unless I run a persistent session strategy, this won't scale well.
So currently, I'm passing it around as a field in each View Model used by each view so it can be returned. Is this a sound approach? I'll be needing other fields to be passed around as well so I'm wondering whether this is a secure and logical way to do it.
So currently, I'm passing it around as a field in each View Model used by each view so it can be returned. Is this a sound approach?
Yes, how you choose to pass it around is up to you, I choose this same approach. You could use TempData, Sessions or even localStorage as an alternative. I think having it in the models (view models) is a good approach because you are explicitly specifying where you want the return url to exist, otherwise it might persist in context that you wouldn't want.
Now the security question because obviously you might be able to see the return url in the browser address field.
As part of Identity Server 4 setup you specify which return url's you are allowed to redirect back to, so I don't think there is any harm in having the users see the redirect url.
Something to consider is what if the user would share the url to someone else in the middle of the authentication process, would they be able to resume from that part of the process that the initial user has stopped? is this something you want in your app?
If you mean reliably instead of securely, write tests which will provide you with confidence that your code works.

how do I force a field to be translated in my Odoo code?

I am developing a module for electronic invoicing, and should express the payment term in spanish, so I am setting a dictionary with all the needed fields, and when I do this:
{
...
'FmaPago': inv.payment_term.name,
...
}
The output file contains the value "name" in english. I've tried something like
_(inv.payment_term.name)
but with the same result.
How should I force the value to be expressed in a defined translation?
The field name of Payment Terms are already translatable. You can change the translation in Odoo by clicking the little button within a field in edit mode.
If you've done that correct, you have to avoid some typical mistakes at code side if you use the old API.
always pass the context
e.g. if you browse the invoice, pass the context, to get all translations correct
use partner language if you want to translate for them
Odoo is using user language in his context, to translate the web client correctly. If you print documents for customers, you want them in customer language of course...
So you maybe need to manipulate the context (key 'lang'). For new API you have to call with_context() to do that.
You must use _() for strings that you want to be able to translate.
You must make translating files *.po (as i remmember) and thats all I think.
Dont forget to check documentation link

Change Theme based on user roles Liferay

I want such a mechanism that will provide different themes depends on different user roles in Liferay.Is there a way that provide me a solution that i can change theme on User roles.
Secondly i want to know that is this is possible programatically or Liferay provides custom supports with this.
any help will be greatly appreciated.
Bad choice
The right way is not to change the theme but to inject something in the page to alter the style.
It's a bad idea to change the theme at runtime depending on the user session. Poor performance due to the invalidated cache every request.
Build a custom portlet and inject it into the theme for every page. Depending on user logic that portlet can inject some javascript to alter css class of html tag.
Is it clear?
Theme is associated with layout (i.e. page). This can be observed in Layout table of liferay. So, even it can be changed using API, but not something that is different at user level, but its associated at page level.
For your requirement, If you have some fixed number of themes, then having different Sites each having one particular theme been applied.
Using Post login hook, you can check for user role and redirect to appropriate site.
Having this approach you can have completely different layout and pages as well depending on user role if you wish you.
We can also use velocity variables such $is_male, $is_female, $time_zone, $language.. to identify user group and can load different CSS file or a parent class in body tag.
Answer might be not useful for Mark who has raised this but future reader might find this useful.
Thanks

Jira SOAP API custom field

Hi I'm am trying to get the list of issues from a JIRA server using the SOAP API provided by JIRA.
I'm trying to filter the issues based on a custom field (and latter I will want to set that custom field).
If I get the list of issue it returns the custom fields for those issues along with them (I get customfieldId, key, values for each custom field) and I can get the custom field with getCustomFields methods provided by the API (to look for the ID of the field with a given name).
The issue I have is that if I login with an account that is not an admin (using the API) I can't call the getCustomFields method (it throws an exception saying I have to be an admin to do that).
My question is: Is there any other way to know which is the ID of the custom field I desire that can be done using a normal user account?
Also if you know how to set a custom field for an issue, it would also be very helpful :) (I would also like to be able to do it with a regular user account).
You have to be an admin to get a list of custom fields. Any 'normal' account can act on the custom fields via the API provided the user knows the customfield ID.
You can set the value of a custom field too, even with a 'normal' account. Again, the user needs the appropriate permissions to do this. Example provided here.
More here and here.
You can also use getFieldsForEdit(token, issueKey), which will return RemoteField[] for all fields available for edit on that issue (even if it has not yet been defined on the issue). It does not require admin permissions, but because it has the word "Edit" in the method, it does require that you have permission to edit the issue (which means, e.g., if the issue is status=Closed, it will raise an exception unless you allow editing closed issues. Unfortunately, I have yet to find a way to retrieve the RemoteField[] list (in order to map id to name), so getCustomFields() and getFieldsForEdit() appear to be the only options.
Have you tried getting a list of issues from the project, picking one, zeroing out the data, and using that as a template? That might work.
SOAP is being deprecated in favor of the REST API, which also has a better method to get this information