Bug 313860

Summary: Misuse of i18n calls in global namespace
Product: [Applications] kinfocenter Reporter: Albert Astals Cid <aacid>
Component: PCIAssignee: David Hubner <hubn3rd>
Status: RESOLVED FIXED    
Severity: normal CC: sitter
Priority: NOR    
Version First Reported In: 4.9.98 RC3   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Albert Astals Cid 2013-01-24 23:56:15 UTC
This won't work, you can't call i18n in the global namespace since it can't
translate anything since the app as not even started yet

./kde-workspace/kinfocenter/Modules/pci/kpci_private.h:438:static const id2name devClass[]={{   0x00,   i18n("Unclassified device")},
./kde-workspace/kinfocenter/Modules/pci/kpci_private.h:462:static const id3name devSubclass[]={ {       0x00,   0x00,   i18n("Non-VGA unclassified device")},
./kde-workspace/kinfocenter/Modules/pci/kpci_private.h:605:static const id4name devInterface[]={        {       0x01,   0x05,   0x20,   i18n("single DMA")},
./kde-workspace/kinfocenter/Modules/pci/kpci_private.h:679:static const id2name capNames[]={{   0x01,   i18n("Power management")},
./kde-workspace/kinfocenter/Modules/pci/kpci_private.h:700:static const id2name devSel[]={      {       0x00,   i18n("Fast")},
./kde-workspace/kinfocenter/Modules/pci/kpci_private.h:708:static const id2name mappingType[]={{        0x00,   i18n("32 bit")},
./kde-workspace/kinfocenter/Modules/pci/kpci_private.h:716:static const id2name headerType[]={  {       0x00,   i18n("Standard")},
./kde-workspace/kinfocenter/Modules/pci/kpci_private.h:724:static const id2name agpRate[]={{    0x01,   i18n("1X")},
./kde-workspace/kinfocenter/Modules/pci/kpci_private.h:739:static const id2name calCycle[]={    {       0x00,   i18n("4 ms")},
./kde-workspace/kinfocenter/Modules/pci/kpci_private.h:749:static const id2name auxCur[]={      {       0x00,   i18n("0 (self powered)")},
./kde-workspace/kinfocenter/Modules/pci/kpci_private.h:762:static const id2name powerState[]={  {       0x00,   i18n("D0")},
./kde-workspace/kinfocenter/Modules/pci/kpci_private.h:771:static const id2name multipleMessage[]={{    0x00,   i18n("1 vector")},
Comment 1 Harald Sitter 2020-01-17 14:26:30 UTC
This seems to be working fine nowadays. Probably because of the new TRANSLATION_DOMAIN define system?

Should we close this bug?
We could probably move the statics into function local scope, that way they'd only get initialized on first use I think, and at that point i18n is probably already set up. Not sure it makes a difference anymore.
Comment 2 Albert Astals Cid 2020-01-17 22:48:20 UTC
Yes, TRANSLATION_DOMAIN helps here