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

404 error when configuring a single language #150

Closed
asad-c opened this issue Oct 10, 2019 · 7 comments
Closed

404 error when configuring a single language #150

asad-c opened this issue Oct 10, 2019 · 7 comments
Assignees
Labels
bug Something isn't working Confirmed I've managed to reproduce the bug. That's great news: chances are I'll solve it. Solved

Comments

@asad-c
Copy link

asad-c commented Oct 10, 2019

In the docs it says the following:
If you need only one language, you can reduce the list to locale.properties and your language folder.

I'm getting the following error when trying to only support a single language:
zone-evergreen.js:2828 GET http://localhost:4201/assets/locale/en-CA/viewer.properties 404 (Not Found)

Here is my html markup:

 <ngx-extended-pdf-viewer 
            [src]="'...'" 
            backgroundColor="#ffffff" 
            [height]="'90vh'"
            [useBrowserLocale]="true" 
            [filenameForDownload]="filenameForDownload"
            [showBookmarkButton]="false"
            [showOpenFileButton]="false"
            [showSidebarButton]="false"
            [showFindButton]="false"
            [showSecondaryToolbarButton]="false"
            language="en-GB">
        </ngx-extended-pdf-viewer>

angular.json:

{
                "glob": "**/locale.properties",
                "input": "node_modules/ngx-extended-pdf-viewer/assets/locale",
                "output": "/assets/locale"
              },
              {
                "glob": "**/*",
                "input": "node_modules/ngx-extended-pdf-viewer/assets/locale/en-GB",
                "output": "/assets/locale/en-GB"
              },
              {
                "glob": "**/*",
                "input": "node_modules/ngx-extended-pdf-viewer/assets/images",
                "output": "/assets/images"
              },
              {
                "glob": "**/pdf.worker.js",
                "input": "node_modules/ngx-extended-pdf-viewer/ngx-extended-pdf-viewer/assets",
                "output": "/assets"
              }

Is this a bug or is the config incorrect? I don't know why it's looking for en-CA.

@stephanrauh stephanrauh self-assigned this Oct 10, 2019
@stephanrauh stephanrauh added the bug Something isn't working label Oct 10, 2019
@stephanrauh
Copy link
Owner

Looks like a bug. Maybe I've introduced it when improving the i18n algorithm. As a workaround, you can add the locale Json to the index.html, together with setting useBrowserLocale="false".

@stephanrauh stephanrauh added the Confirmed I've managed to reproduce the bug. That's great news: chances are I'll solve it. label Oct 12, 2019
stephanrauh added a commit that referenced this issue Oct 12, 2019
…orry, dear Canadians, for changing the default - I love your country, but I think it makes sense to follow the population size and to follow the standards set by major companies like Microsoft).
stephanrauh added a commit that referenced this issue Oct 13, 2019
stephanrauh added a commit that referenced this issue Oct 13, 2019
… if there's already a more specifiy file (e.g. "en-GB.properties")
stephanrauh added a commit that referenced this issue Oct 13, 2019
… if there's already a more specifiy file (e.g. "en-GB.properties")
@stephanrauh
Copy link
Owner

I believe to have successfully solved your issue with version 1.6.0-rc.1. Would you mind to run a test? There are still unsolved edge cases, such as languages like "en-NONSENSE" which don't exist, but I guess we can get away with ignoring these edge cases.

@asad-c
Copy link
Author

asad-c commented Oct 14, 2019

The PDF displays now, but there is a console error:

zone-evergreen.js:2828 GET http://localhost:4201/assets/locale/en-US/viewer.properties 404 (Not Found)
viewer-es5.js:14690 http://localhost:4201/assets/locale/en-US/viewer.properties not found.

I have to support IE11, so switched to the es5 version of the scripts.

@stephanrauh
Copy link
Owner

Oops - same here. Both with the IE11 version and the ES2015 version.

stephanrauh added a commit that referenced this issue Oct 14, 2019
… if there's already a more specific file (e.g. "en-GB.properties") (this time for real)
@stephanrauh
Copy link
Owner

stephanrauh commented Oct 14, 2019

Now I'm positive I've solved the issue. Would you mind to test again?

Thanks,
Stephan

@NishadAbdul
Copy link

NishadAbdul commented Jul 27, 2020

I am having the same issue when I tried to configure single language - en-US. PDF loads for me but local.properties logs console error as 404 along with more than 250 warnings which is not good for an application anyways. Some are:

viewer.min.js:21 "en" resource not found
#toggle_sidebar is undefined
Translation for the key #findbar_label is missing.
Warning: parseDestDictionary: unsupported action type "ResetForm".
viewer.min.js:21 PDF viewer: ngx-extended-pdf-viewer running on pdf.js 2.6.57
viewer.min.js:21 PDF 845996c0d5824d68b37adfcb0b462c46 [1.4 Acrobat Distiller 6.0 (Windows) / PageMaker 7.0] (PDF.js: 2.6.57) modified by ngx-extended-pdf-viewer)

Angular.json

{
"glob": "/locale.properties",
"input": "node_modules/ngx-extended-pdf-viewer/assets/locale",
"output": "/assets/locale"
},
{
"glob": "
/",
"input": "node_modules/ngx-extended-pdf-viewer/assets/locale/en-US",
"output": "/assets/locale/en-US"
},
{
"glob": "**/
",
"input": "node_modules/ngx-extended-pdf-viewer/assets/images",
"output": "/assets/images"
},
{
"glob": "/pdf.min.js",
"input": "node_modules/ngx-extended-pdf-viewer/assets",
"output": "/assets"
},
{
"glob": "
/pdf.worker.min.js",
"input": "node_modules/ngx-extended-pdf-viewer/assets",
"output": "/assets"
},
{
"glob": "**/viewer.min.js",
"input": "node_modules/ngx-extended-pdf-viewer/assets",
"output": "/assets"
}

@stephanrauh
Copy link
Owner

@NishadAbdul Strange. I believe you approach works, but maybe you've missed a file or a folder. In general, I recommend simply copying the entire assets folder, as described here: https://pdfviewer.net/getting-started

That approach adds a few hundred kilobytes to your assets folder, but unless you wrap it into a Cordova app, that's no disadvantage. The clients only loads the files it really needs.

If you're sure you need only a single language, there's a better approach. The folder node_modules/ngx-extended-pdf-viewer/assets/inline-locale-files contains a lot of HTML snippets. Just copy the content of the en-US.html file into your index.html. If you set the attribute useBrowserLocale="false", the JSON file of the HTML snippet is used for the translations.

If you're unhappy to put the JSON file into the index.html, you can put it somewhere else later (after the first successful test). It just needs to be part of the DOM tree when ngx-extended-pdf-viewer is initialized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Confirmed I've managed to reproduce the bug. That's great news: chances are I'll solve it. Solved
Projects
None yet
Development

No branches or pull requests

3 participants