You are not logged in.

Announcement

 Téléchargez la dernière version stable de GLPI      -     Et vous, que pouvez vous faire pour le projet GLPI ? :  Contribuer
 Download last stable version of GLPI                      -     What can you do for GLPI ? :  Contribute

#1 2024-01-31 10:44:21

SomeDude
Member
Registered: 2023-11-22
Posts: 62

How to rename a Menu point

Hello we want to rename the Menu Point Devices to something else. I read about the .po but could only manage to find myself to /usr/share/locale/de/LC_MESSAGES and I have not found out how to change that point yet.

If anybody has experience with that please feel free to help me

Offline

#2 2024-01-31 13:39:57

cconard96
Moderator
Registered: 2018-07-31
Posts: 2,809
Website

Re: How to rename a Menu point

The GLPI translations are in the "locales" folder inside GLPI.
Ideally, you would be using the Rename GLPI Strings plugin (available through GLPI-Network) to change these though.
https://plugins.glpi-project.org/#/plug … leoverride


GLPI Collaborator and Plugin Developer.
My non-English comments are automated translations. Sorry for any confusion that causes.
Mes commentaires non anglais sont des traductions automatiques. Désolé pour toute confusion qui cause.
Mis comentarios que no están en inglés son traducciones automáticas. Perdón por cualquier confusión que cause.

Offline

#3 2024-01-31 13:52:53

lapis_lazuri
Member
From: Moskau
Registered: 2024-01-31
Posts: 3

Re: How to rename a Menu point

I've had an experience with changing GLPI interface strings.
(I do not give any warranty but it worked for me):

0. Make a backup of both .po and .mo files with your locale ../glpi/locales in case something wrong happens;
1. Find a .po file with your language in server folder;
2. Open in any text editor and find string that you want to modify (by Ctrl+F) and change it to desired value;
3. Go to any .po to .mo converter (i.e. po2mo net) and get your .mo file based on .po;
4. Move both .po and .mo files into ../glpi/locales
5. Go to the GLPI panel, turn on debug mode;
6. Go to Setup > General > Performance > Reset Translation Cache
7. Now you may see new strings on your interface

Downside: after updating to new version I had to do it all again

Offline

#4 2024-01-31 14:01:54

lapis_lazuri
Member
From: Moskau
Registered: 2024-01-31
Posts: 3

Re: How to rename a Menu point

I also named them alike (i.e. de_DE.po and de_DE.mo)

Offline

#5 2024-02-01 08:40:27

SomeDude
Member
Registered: 2023-11-22
Posts: 62

Re: How to rename a Menu point

could it be possible to create a script to automate this task ? or a crontab

Offline

#6 2024-02-01 11:21:50

lapis_lazuri
Member
From: Moskau
Registered: 2024-01-31
Posts: 3

Re: How to rename a Menu point

I think it is technically possible.
In script you may write some code to read contents of files, modify them, it is up to you to choose your scripting language.

I know in Python there a polib library that allows you to convert .po to .mo. Combine it with reading file and modifying its values in your code

Here's an example (feel free to fix me. Also would recommend firstly running in test environment):

import polib
import os

def modify_glpi_strings(language_code, original_string, modified_string):
    po_file_path = f'../glpi/locales/{language_code}.po'
   
    po = polib.pofile(po_file_path)

    for entry in po:
        if original_string in entry.msgid:
            entry.msgstr = modified_string

    po.save()

    mo_file_path = f'../glpi/locales/{language_code}.mo'
    po.save_as_mofile(mo_file_path)

    return mo_file_path

language_code = 'ru_RU'
original_string = 'Original Value'
modified_string = 'Modified Value'
mo_file_path = modify_glpi_strings(language_code, original_string, modified_string)
print(f'Modified .mo file saved at: {mo_file_path}')

Then just add Python script to Cron scheduler. Or Docker.

on your server open cron
crontab -e

Add line to run everyday at 17:30:
30 17 * * * /usr/bin/python3 /path/to/glpi_string_modifier.py

However I would recommend just using plugin that moderator suggested above

Offline

Board footer

Powered by FluxBB