Create language FILE

Post

Posted
Rating:
#3525 (In Topic #665)
Joe
Avatar
Standard member
Joe is in the usergroup ‘Honoured member’
I see there's a way to create a new language but there isn't a way to create a language file other than manually.

I'm starting to have so much content that repeats itself, and if something needs changing I'm going to need to change it in 10 different areas, so I want to be able to create a new language file, let's say:

custom_file.ini

…and specify my own strings. Question is, how can I reference this custom file?

I could just add everything to global.ini but my OCD tells me I need to keep it all organized and separate.
Online now: No Back to the top

Post

Posted
Rating:
#3529
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’
I think you mean in a template.

{!custom_file:SOME_STRING}

The colon scoping here is a special syntax we support. It auto-loads the file if not already loaded.


Become a fan of Composr on Facebook or add me as a friend. Add me on on Mastodon. Follow me on Minds (where I am most active). Support me on Patreon

Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Online now: No Back to the top

Post

Posted
Rating:
#3727
Avatar
Site staff
Adam Edington is in the usergroup ‘Super-moderators’
Is there a correct way to reference a language file via catalogue select lists? On the actual edit page it does show the translated DE string in the list dropdown as Mensch instead of Human when using {!KAL:HUMAN} as a list entry, but on the actual view screen it shows the raw Tempcode.

Also to extend upon the original question Joe asked, how do we get this custom language file to be loaded with all the others so we don't need to use the !ref: in templates.
Online now: No Back to the top

Post

Posted
Rating:
#3730
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’
Is there a correct way to reference a language file via catalogue select lists? On the actual edit page it does show the translated DE string in the list dropdown as Mensch instead of Human when using {!KAL:HUMAN} as a list entry, but on the actual view screen it shows the raw Tempcode.

I'm afraid that I can't follow these words. Are we talking about the lists to select a catalogue when you add/edit a category or entry? Are we talking about fields with a field type of referencing a catalogue? Are we talking about fields with a field type of referencing a catalogue entry? Where exactly is the 'Tempcode being input? Because it couldn't be input in a reference to a catalogue or catalogue entry, that doesn't make sense. And it couldn't be the name of the catalogue itself, because codenames don't support special characters. And I just tested it in a catalogue title and it always showed as plain text.


Become a fan of Composr on Facebook or add me as a friend. Add me on on Mastodon. Follow me on Minds (where I am most active). Support me on Patreon

Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Online now: No Back to the top

Post

Posted
Rating:
Item has a rating of 5 (Liked by Adam Edington)
#3731
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’
Also to extend upon the original question Joe asked, how do we get this custom language file to be loaded with all the others so we don't need to use the !ref: in templates.

You could make a startup hook. Similar to this, but doing require_lang:
https://github.com/ocproducts/composr/blob/master/sources_custom/hooks/systems/startup/columns.php


Become a fan of Composr on Facebook or add me as a friend. Add me on on Mastodon. Follow me on Minds (where I am most active). Support me on Patreon

Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Online now: No Back to the top

Post

Posted
Rating:
#3732
Avatar
Site staff
Adam Edington is in the usergroup ‘Super-moderators’
issue_admin.png issue_display.png

Hope this makes it clearer, when editing the catalogue entry it actually shows the string from the language file in the dropdown menu as "Human". Just doesn't show it correctly when viewing the entry. I realised I couldn't translate the list values directly when switching language, so I figured a language file might be the solution.

EDIT: Perhaps I could just leave the list values as English (not ideal for a multilanguage site) and can do something at the template level to display the translations from the respective language files when it comes to viewing the entries?

Last edit: by Adam Edington

Online now: No Back to the top

Post

Posted
Rating:
Item has a rating of 5 (Liked by Adam Edington)
#3734
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’
Oh I see. Fixed. Comcode will be consistently supported for list field options now.


Become a fan of Composr on Facebook or add me as a friend. Add me on on Mastodon. Follow me on Minds (where I am most active). Support me on Patreon

Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Online now: No Back to the top

Post

Posted
Rating:
#3736
Avatar
Site staff
Adam Edington is in the usergroup ‘Super-moderators’
Awesome sauce :)
Online now: No Back to the top
1 guest and 0 members have just viewed this.

Statistics

Forum statistics:
  • 2,052 topics, 7,195 posts, 10,829 members
  • Our newest member is helpfulinsight
Back to Top