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

Translation for the key is missing. #559

Closed
asohail-numtra opened this issue Nov 20, 2020 · 10 comments
Closed

Translation for the key is missing. #559

asohail-numtra opened this issue Nov 20, 2020 · 10 comments
Assignees
Labels
Original topic solved - ticket contains followup The original problem has been solved. However, as discussions go, a new issue has been raised. Solved user support You've got a question, or a misconfiguration, or simply need a hint how to get things up and running

Comments

@asohail-numtra
Copy link

asohail-numtra commented Nov 20, 2020

(see next message)

@asohail-numtra
Copy link
Author

asohail-numtra commented Nov 20, 2020

I am getting a long list of warnings in Chrome
l10n.js:836 Translation for the key #CONSTANT_NAME is missing.

I have tried all option mentioned on
#150
but didn't get any success.

Environment:
Angular 6
Chrome
Windows 10

package.json:
"ngx-extended-pdf-viewer": "^6.2.0-alpha.0"

angular.json:

{
  "glob": "**/*",
  "input": "node_modules/ngx-extended-pdf-viewer/assets/",
  "output": "/assets/"
}

HTML code:

 <ngx-extended-pdf-viewer 
      [base64Src]="pdFileData" 
      [useBrowserLocale]="true" 
      height="50vh"
      [showOpenFileButton]="false"
      [showBookmarkButton]="false"
      [showSecondaryToolbarButton]="false"
      [showPresentationModeButton]="true"
      [textLayer]="true">
    </ngx-extended-pdf-viewer>

Issue screenshot:
image

Please help me to fix this.

Thanks

@stephanrauh
Copy link
Owner

Can you upload a screenshot of the network tab? Probably your application can't access the language files.

@asohail-numtra
Copy link
Author

asohail-numtra commented Nov 20, 2020

network

network-2

@stephanrauh
Copy link
Owner

All right, that clarifies things a lot. At first glance, the locale.properties is loaded correctly, but fails to load the en-GB/viewer.properties file containing the actual translations. (Or any of the other 132 language files, depending on where you're living).

However, you're also showing the content of the locale.properties. That looks like the index.html of Angular. Instead of showing the error code 404, your server is configured to redirect you to the index.html.

Here's what to do:

  • Run ng band have a look at the dist folder. It should find a folder called assets/locale. That folder, in turn, contains 132 folder and the locale.properties file.
  • If it doesn't, there's something wrong with your angular.json. But that's unlikely.
  • Most likely, the browser loads the locale.properties from the wrong path. Using the standard configuration, the path is localhost:4200/assets/locale.properties. But many people use a different context path. If there's a difference, copy the locale folder to the correct path, or use the new attribute localeFolderPath to tell the PDF viewer where to find the locale files.

@stephanrauh
Copy link
Owner

Does this solve your bug? Usually I don't close the ticket until I know it's solved, so I'd appreciate a short "ping". :)

Best regards,
Stephan

@stephanrauh stephanrauh self-assigned this Nov 20, 2020
@stephanrauh stephanrauh added user support You've got a question, or a misconfiguration, or simply need a hint how to get things up and running waiting for the user's answer labels Nov 20, 2020
@asohail-numtra
Copy link
Author

Please let me check all stuff.
I will update you shortly.
Thanks

@asohail-numtra
Copy link
Author

asohail-numtra commented Nov 20, 2020

@stephanrauh, you save my day. Thank you very much. 👍
Your help and guidelines are really appreciated. :)

Actually, I am using two child app under a single angular environment. I think that's the reason, the browser loads the locale.properties from the wrong path.

I have added this line in PDF viewer,
localeFolderPath="dist/PROJECT_NAME/assets/locale"

That fixed the issue.

Now my HTML code is:

<ngx-extended-pdf-viewer 
      [base64Src]="pdfFileData" 
      [useBrowserLocale]="true" 
      height="50vh"
      [showOpenFileButton]="false"
      [showBookmarkButton]="false"
      [showSecondaryToolbarButton]="false"
      [showPresentationModeButton]="true"
      [textLayer]="true"
      **localeFolderPath="dist/PROJECT_NAME/assets/locale"**>
    </ngx-extended-pdf-viewer>

Once again thanks for the quick reply and guidance.

Best Regards,
Adnan Sohail

@asohail-numtra
Copy link
Author

The last thing, I have another warning for some specific pdf files (not for all files).

util.js:337 Warning: The font embedded in the PDF file contains errors: TT: undefined function: 32

Can you please guide me, how can I get rid of this one?

@stephanrauh
Copy link
Owner

stephanrauh commented Nov 21, 2020

I'm afraid I can't. I've seen the "undefined function: 32" message several times, too. As far as I can see, the PDF file is broken, but it's not broken too badly to be displayed properly.

@timvandermeij Tim, this time I don't request your help, but I'm curious. Google didn't manage to shed light on the topic. What's causing the message "Warning: The font embedded in the PDF file contains errors: TT: undefined function: 32"?

@stephanrauh stephanrauh added Solved Original topic solved - ticket contains followup The original problem has been solved. However, as discussions go, a new issue has been raised. and removed waiting for the user's answer labels Nov 21, 2020
@timvandermeij
Copy link

timvandermeij commented Nov 21, 2020

PDF.js tries to recover bad fonts, i.e., font data that doesn't adhere to the specification. If it falls back to recovery mode, it prints this message. See also mozilla/pdf.js#3768 (comment). In short, the font data is invalid, but PDF.js is able to recover. To get rid of this, the PDF file should be regenerated with valid font data.

Note that it's a warning, not an error, generated here: https://github.com/mozilla/pdf.js/blob/46e60a266cc9bdb6ff952accc3957798fcb29826/src/core/fonts.js#L2524-L2545

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Original topic solved - ticket contains followup The original problem has been solved. However, as discussions go, a new issue has been raised. Solved user support You've got a question, or a misconfiguration, or simply need a hint how to get things up and running
Projects
None yet
Development

No branches or pull requests

3 participants