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

APA 6th for translator roles #33

Open
HughP opened this issue Jun 3, 2021 · 3 comments
Open

APA 6th for translator roles #33

HughP opened this issue Jun 3, 2021 · 3 comments

Comments

@HughP
Copy link

HughP commented Jun 3, 2021

Greetings,

I needed to add a translator so I did. Translators can be attached to any resource type. But in my templates I only added them to books as that is all I needed sofar. Ideally there would be a better way than to add translator to each title... maybe a title template is needed. Here is the two part solution I came up with:

  1. I duplicated the authorPart and modified it to become translatorPart (if the authorPart is modified to include handle corporate or "literal" names, then those adjustments should also be made to the translatorPart literal value in CLS-JSON #26 ):
{{/* BEGIN translator */}}
{{- define "translatorPart" }}
  {{- $translators := .translator }}
  {{- if $translators -}}
  {{- $totalTranslators := len $translators -}}
  {{- range $translatorIndex, $translator := $translators -}}
  <span itemprop="author" itemscope itemtype="https://schema.org/Person">
     {{- with $translator.given -}}
    <meta itemprop="givenName" content="{{ . }}" />{{ substr . 0 1 }}.&nbsp;
    {{- end -}}{{/* First letter (initial). */}}
    {{- with $translator.secondInitial -}}
    <meta itemprop="additionalName" content="{{ . }}" />
    {{- substr . 0 1 -}}.&nbsp;{{- end -}}
   {{- with $translator.family -}}
    <span itemprop="familyName">{{ . }}</span>
    {{- end -}}
  </span>
  {{- if and (gt $totalTranslators 1) (lt (add $translatorIndex 2) $totalTranslators) -}},&#32;
  {{ end -}}
  {{ if eq $totalTranslators (add $translatorIndex 2) -}}&#32;&amp;&#32;{{ end -}}{{/* Last name has ampersand */}}
  {{- end -}}
  {{- else -}}{{/* Fallback if no translators are specified */}}
  {{- end -}}
{{- end -}}{{/* END translator */}}
  1. In the book type after title add:
{{- if isset . "translator" -}}&#32;(<span itemprop="translator">{{- template "translatorPart" . -}}</span>){{- end -}}
@loup-brun
Copy link
Owner

Thank you! 😊 I’m getting everything ready to integrate all these changes. Stay tuned!

@HughP
Copy link
Author

HughP commented Jun 3, 2021

I hope your comment doesn't mean that I am providing templates you have already created but have not yet published!

@loup-brun
Copy link
Owner

@HughP no don’t worry, it’s not already created, thanks for your contribution :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants