Closed vidhya03 closed 6 years ago
@vidhya03 can you do a PR?
As per my understanding, SERVER_API_URL
is meant to point to remote server (when server side code is deployed separately from frontend code) and shouldn't be used to access frontend i18n resources (i18n access should always be relative to frontend deployment).
If I have correctly understood this issue, then, the requirement is to provide a way to customize i18n bundle path and that should be done in ng-jhipster
Hi @deepu105 , thanks a lot, i expected your reply..
Could you please help. so that i can fix
export function translatePartialLoader(http: HttpClient) {
return new TranslateHttpLoader(http, ${process.env.SERVER_API_URL}+'/i18n/', `.json?buildTimestamp=${process.env.BUILD_TIMESTAMP}`);
}
@vidhya03 I think @vishal423 is right that the SERVER_API_URL
is only used to specify the backend API URL. Your i18n
resources should be hosted relative to your client.
Have you tried setting the <base href="./" />
to /
instead of ./
in your custom index.html files?
Vishal is right. We can't change the lib for non standard use cases.
On Fri, 2 Nov 2018, 9:24 pm Jon Ruddell <notifications@github.com wrote:
@vidhya03 https://github.com/vidhya03 I think @vishal423 https://github.com/vishal423 is right that the SERVER_API_URL is only used to specify the backend API URL. Your i18n resources should be hosted relative to your client.
Have you tried setting the
to / instead of ./ in your custom index.html https://github.com/jhipster/jhipster-sample-app/blob/master/src/main/webapp/index.html#L4 files? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/jhipster/generator-jhipster/issues/8668#issuecomment-435488517, or mute the thread https://github.com/notifications/unsubscribe-auth/ABDlF2QXdJGdi0m9mtCxv_etRiXRZLIKks5urKoFgaJpZM4X-pv- .
@ruddell yes i tried setting base href, however I'm integrating jhipster into static sites hugo,
there were multiple places we use jhipster app. (sample jhipster app but different pages we redirect the router based on webcomb.html/esb.html) this page has both static and dynamic content.
https://
my concern is at-least we can customize the i18n path , instead of relative .
@vidhya03 if you can do a PR to update the lib in such a way that it doesnt affect the normal applications then I can take a look and merge it
i'm closing this as its not a bug
Hi @vidhya03 , How did you fix your issue. I need to add a prefix to my json file.
Hi Chandan, @coolduebtn
I have tricked it in my webpack scripts webpack.common.js,
new MergeJsonWebpackPlugin({
output: {
groupBy: [
{ pattern: './src/main/webapp/i18n/en/*.json', fileName: './i18n/en.json' },
{ pattern: './src/main/webapp/i18n/en/*.json', fileName: './site/i18n/en.json' },
{ pattern: './src/main/webapp/i18n/de/*.json', fileName: './i18n/de.json' },
{ pattern: './src/main/webapp/i18n/de/*.json', fileName: './site/i18n/de.json' }
// jhipster-needle-i18n-language-webpack - JHipster will add/remove languages in this array
]
}
})
Hi, I have developed a site using Jhipster, for customer need it must be deployed using a web context different from / , e.g. /CustomerPortal
. Setting servlet context
and BaseHrefWebpackPlugin({ baseHref: '/CustomerPortal' })
, all work well. Only the resolution of file i18n path is wrong. I follow @vidhya03 suggestion to set prefix for i18 resource resolution in webpack.common.js, but it dosen't work for me, when I inspect chrome I always see error 404 (not found) for i18n files because the base context in the requests is omitted.
The request url is always http://my.base.portal/i18n/en.json
instead of http://my.base.portal/CustomerPortal/i18n/en.json
Any suggestion? Thanks in advance, Giovanni
Using JHipster version installed locally in current project's node_modules Executing jhipster:info Options: from-cli: true Welcome to the JHipster Information Sub-Generator
JHipster Version(s)
JHipster configuration, a
.yo-rc.json
file generated in the root folder.yo-rc.json file
JDL for the Entity configuration(s)
entityName.json
files generated in the.jhipster
directoryJDL entity definitions
Environment and Tools
java version "1.8.0_181" Java(TM) SE Runtime Environment (build 1.8.0_181-b13) Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)
git version 2.19.1.windows.1
node: v8.12.0
npm: 6.4.1
yarn: 1.10.1
Overview of the issue
Jhipster JhiLanguageService always points to relative path
I have configured the SERVER_API_URL in webpack.common.js to
SERVER_API_URL: 'http://localhost:9000/'
however the JhiLanguageService is always pointed to relative path
i have also configured in mycloud-app\src\main\webapp\app\app.constants.ts
export const SERVER_API_URL = 'http://localhost:9000/';
still the url pointing to relative path http://localhost:9000/site/product/i18n/en.json?buildTimestamp=1540574017051however rest of the api calls are using the SERVER_API_URL, for eg
is it bug or where do we configure the languageservice path.
Motivation for or Use Case
If SERVER_API_URL is configured , it should use the SERVER_API_URL, or base href or some other way to configure the translate service path in TranslateHttpLoader
Reproduce the error
I am integrating the jhipster in to the static sites. which has path to multiple pages, I have added an entry in webpack.common.js under the CopyWebpackPlugin Before:
After: Added this { from: './src/main/webapp/site/', to: 'site' }, hence the file looks like the below
Under the site/ directory they are multiple index.html , i have added the js in all index.html , so that where ever user navigate our angular will load on that page.
Suggest a Fix
As mention here https://github.com/ngx-translate/core/issues/802#issuecomment-375880371 we can change the logic here