JHipster new module : cannot add translation - jhipster

I have added a new module with several components inside JHipster. I would like so add the translation in the html part with the JHipsterTraslationService and tried to do it but I do not know. I think I have to suscribe to the new service but I don't know how.

Jhipster use jhiTranslate in the html, for example: <label class="form-control-label" jhiTranslate="myApp.myComponent.myWelcome">My default welcome text</label>,
this refers to the value of the field in your translation .json file, it will look for it in that file and replace it with the value it has. Otherwise, it will show the value, "My default welcome text".
When you create a component with jhipster using angular cli, the translation files are created in each language folder of your application.(example: myApplicationName\src\main\webapp\i18n\en)
This is the example they put in their documentation (Generating Components, Directives, Pipes and Services) for create components:
ng generate component my-new-component
ng g component my-new-component # using the alias
# Components support relative path generation
# Go to src/app/feature/ and run
ng g component new-cmp
# your component will be generated in src/app/feature/new-cmp
# but if you were to run
ng g component ../newer-cmp
# your component will be generated in src/app/newer-cmp
I believe that it is easy and better to use this method of creation, because it will create all the necessary files, be it a component, service, directive, route, etc.
Additionally, if you have already created the components, you will have to manually create each .json file in its corresponding folder according to the languages of your application. You can also add another language to your application (How to add languages after project generation?).
Other way.... U can try add other language, with the generator. And check that files was added and what change, with this u can know what files or subscriptions can change.
I hope this helps. ;)

Related

Is it possible to edit ng generate?

I was wondering if I could customize what would ng generate for angular does. For example, if I want to generate a component, I would like the command to automatically edit my routes file and automatically add a new link based on what was written. Or for another example, I want to use a set of services to be included in my newly-generated component.
This solution would solve the problem of me going around, and importing each individual service to any new component that I am going to generate. So is there any way that I could modify the behavior of the ng generate command or even do some additional things on top of what it does?

How to rename an existing Hybris extension

I am working on Hybris and I generated a new extension using hybris command (ant extgen) with default settings. During extension generation, I did not change default values like I let the project name to be "training". I started developing some code just for the sake of trying it but now I wrote quite a lot of code and instead of generating a new extension, I am trying to rename "training" to a new name which is more suitable for my project.
My question is - Is there any shortcut to rename "training" to a new name. By rename I don't mean standard intellij or eclipse module rename but also updating all extension specific properties which are referring to extension name "training". Is there any hybris ant command for it?
Here is the way I can think of.
You can declare your extension as a template for extgen and then generate a new extension based on it with a new name and structure.
Let me take training as your current extension which you want to convert to some other name. Below are the steps you need to perform.
Make sure your extension (training) is there in the localextensions.xml
Update extensioninfo.xml to mark the extension as a template by adding below meta tag
<meta key="extgen-template-extension" value="true"/>
Look like
<coremodule generated="true" manager="org.training.jalo.TrainingManager" packageroot="org.training"/>
<meta key="extgen-template-extension" value="true"/>
<webmodule jspcompile="false" webroot="/training"/>
Create an extgen.properties inside training extension/folder with below properties
Please note, If your current extension is with a different name then training in that case you need to change below values accordingly.
extgen.properties:
YEXTNAME_TOKEN=training
YMODULE_TOKEN=training
YMODULE_PACKAGE_ROOT=training
YMODULE_CLASS_PREFIX=training
YPACKAGE_TOKEN=org.training
YMANAGER_TOKEN=TrainingManager
YCLASSPREFIX_TOKEN=Training
YGENERATED_TOKEN=Generated
Run ant extgen and select your extension (training) from the given selection option and give the name and package the way you want when it prompt for it.
Now replace training extension with the newly created extension inside localextensions.xml
Test and patch wherever needed! :-)
I don't think so. It might also be easier just to create a new one and move the code into the new extension.
No it is not possible. The generated extension itself was created from a template where the word "training" is inserted into many places (class names, package names, configurations...) .
The other approach would be to look into the ext-template folder (6.7). There are all templates. Search for any token in the templates and make appropriate change in your generated extensions.
Depending on the amount of your extensions, it will also take some time... and you need to understand how extgen works, first.

Can you remove NetSuite Bundles after installation

I am working on a NetSuite instance that had custom(contractor/SuiteScript) work installed via a bundle, but it is not a third party product but made for this system. Now there are 2 listings in the dropdown for each file. In other words, if I am adding a file as a library, it shows up twice and I don't know which reference is the correct one to choose. I used search to find the duplicate file name is in the bundle install. Can I safely remove or delete the bundle? thanks any help is appreciated.
You cannot typically remove individual files from a bundle. If you do not need the functionality of the bundle anymore than you can remove it at your discretion by going to Customization>SuiteBundler>Search & Install Bundles>List, then under the action icon click 'Uninstall'.
I wouldn't try to delete a script library from a bundle folder. Even if you are uploading an identical library there may be references in the bundle scripts to the original library that will be broken when if you delete it.
If you are wondering which one you are selecting from the drop down one thing you could do is figure out the internal id of your library file then run a search on your script file that pulls in the library file id's and make sure that they match.

How to Remove Entity Completely in Liferay (include class in JAR file)

I am using Liferay 6.2 GA5 Community Edition.
Sample case I have 2 entities in my service.xml, let's say entity A & B.
When I run Service Builder then it will generate many JAVA files in my source code, and also generate JAR file located in
".\my-app\liferay-plugins-sdk-6.2\portlets\my-app-portlet\docroot\WEB-INF\lib\my-app-service.jar"
I open it with 7-zip, and I can see in package com.mycompany.myapp.model contains classes of entity A & B.
Then I try to remove entity A in service.xml, and I have removed the corresponding JAVA files generated in my source code, then I run Service Builder again, but inside my-app-service.jar, entity A is still exist.
How do I completely remove it from JAR file? because in my case, Service Builder will not remove it, although I have remove generated JAVA files manually.
ServiceBuilder is a code generator, thus it only generates new code.
If you want to get rid of the once generated code, there's a lot more than just the java classes to get rid of: Spring configuration, Hibernate configuration etc. are there as well for you to take care of. All of these will have to be deleted manually. And if the code still remains in the jar, good old ant clean (or whatever build environment you use) should get rid of the my-app-service.jar file (which you otherwise also can also just delete manually, so that it will be rebuilt next time a build process or ServiceBuilder runs)
I recommend searching for occurrences of A in all your project's files to see if you still find leftovers, because otherwise some component might complain at runtime that a declarated class can't be found.

Liferay login portlet display text change

Change display name in login portlet from “Screen Name” to “Username”. As per discussion in liferay forums I am assuming that it can be done by using creating hook. Is there any easy way to change the display text.
As reported by discussion forum the best way to do it it's a hook. Your choice if you prefer change login jsp or change the "screen-name" resource bundle properties files. Be aware that changing screen-name label affect whole portal and wherever screen-name label was used (not only login portlet).
If you don't want write a hook, you can try to add to Liferay web application a file named Language-ext.properties within the WEB-INF\classes\content (if content dir doesn't exist create it). Edit Language-ext.properties and add a line with screen-name=Username. Restart Liferay. It should works.
Be aware that language specific version of Language properites files takes precedence over "-ext" version and location specific version takes precedence over language version. If your portal-impl contains language/location specific version you have to ovverride it with relative language specific ext file (e.g. Language-ext_en.properties)

Resources