Software Localization from DLL

Just starting out? Need help? Post your questions and find answers here.
dempdeezzpp
User
User
Posts: 11
Joined: Wed Feb 03, 2021 12:04 am

Software Localization from DLL

Post by dempdeezzpp »

This release Software Localization from DLL.
You can also add other files yourself as pictures in different languages.
You can find it here on the forum.
How is it possible to put all languages in one DLL, but I don't know how to call them!
PS: Use the resource editor or Pelles C to make DLL

Extract Icon and load)
IdIcon1=ExtractIcon_(0,SystemPath+"\SetupAPI.dll",29)
...........
Download here sample ZIP http://depositfiles.com/files/r2a5r851o
dempdeezzpp
User
User
Posts: 11
Joined: Wed Feb 03, 2021 12:04 am

Re: Software Localization from DLL

Post by dempdeezzpp »

NB! Ups: The resource editor = open the text editor and vrite

Code: Select all

STRINGTABLE 
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
{
  10002, 	"Properties"
  10003, 	"Exit"
  10004, 	"Undo"
  10005, 	"Redo"
  10006, 	"Cut"
  10007, 	"Copy"
  10008, 	"Paste"
  10009, 	"Insert"
  10010, 	"Delete"
  10011, 	"Delete word"
  10012, 	"Select all"
  10013, 	"Find"
  10014, 	"Find next"
  10015, 	"Replace"
}
STRINGTABLE 
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
{
  10016, 	"Properties"
  10017, 	"Exit"
  10018, 	"Undo"
  10019, 	"Redo"
  10020, 	"Cut"
  10021, 	"Copy"
  10022, 	"Paste"
  10023, 	"Insert"
  10024, 	"Delete"
  10025, 	"Delete word"
  10026, 	"Select all"
  10027, 	"Find"
  10028, 	"Find next"
  10029, 	"Replace"
}
And save as *.rc file
Create emty *pb proect and add *.rc file to resources.
Save as SHARED DLL
breeze4me
Enthusiast
Enthusiast
Posts: 521
Joined: Thu Mar 09, 2006 9:24 am
Location: S. Kor

Re: Software Localization from DLL

Post by breeze4me »

You can try the following two methods.
Test using the following rc file example.

BTW, I recommend Resource Hacker when compiling resource dll files.

Code: Select all

STRINGTABLE 
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
{
  10002, 	"Properties 1"
  10003, 	"Exit 1"
  10004, 	"Undo 1"
  10005, 	"Redo 1"
  10006, 	"Cut 1"
  10007, 	"Copy 1"
  10008, 	"Paste 1"
  10009, 	"Insert 1"
  10010, 	"Delete 1"
  10011, 	"Delete word 1"
  10012, 	"Select all 1"
  10013, 	"Find 1"
  10014, 	"Find next 1"
  10015, 	"Replace 1"
  10016, 	"Properties 1-1"
  10017, 	"Exit 1-1"
  10018, 	"Undo 1-1"
  10019, 	"Redo 1-1"
  10020, 	"Cut 1-1"
  10021, 	"Copy 1-1"
  10022, 	"Paste 1-1"
  10023, 	"Insert 1-1"
  10024, 	"Delete 1-1"
  10025, 	"Delete word 1-1"
  10026, 	"Select all 1-1"
  10027, 	"Find 1-1"
  10028, 	"Find next 1-1"
  10029, 	"Replace 1-1"
}

STRINGTABLE 
LANGUAGE LANG_DUTCH, SUBLANG_DUTCH
{
  10002, 	"Properties 2"
  10003, 	"Exit 2"
  10004, 	"Undo 2"
  10005, 	"Redo 2"
  10006, 	"Cut 2"
  10007, 	"Copy 2"
  10008, 	"Paste 2"
  10009, 	"Insert 2"
  10010, 	"Delete 2"
  10011, 	"Delete word 2"
  10012, 	"Select all 2"
  10013, 	"Find 2"
  10014, 	"Find next 2"
  10015, 	"Replace 2"
  10016, 	"Properties 2-2"
  10017, 	"Exit 2-2"
  10018, 	"Undo 2-2"
  10019, 	"Redo 2-2"
  10020, 	"Cut 2-2"
  10021, 	"Copy 2-2"
  10022, 	"Paste 2-2"
  10023, 	"Insert 2-2"
  10024, 	"Delete 2-2"
  10025, 	"Delete word 2-2"
  10026, 	"Select all 2-2"
  10027, 	"Find 2-2"
  10028, 	"Find next 2-2"
  10029, 	"Replace 2-2"
}

Code: Select all

Macro MAKELANGID(p, s)
  (((s) << 10) | (p))
EndMacro

#Method = 0

;Define LangID = MAKELANGID(#LANG_DUTCH, #SUBLANG_DUTCH)
Define LangID = MAKELANGID(#LANG_ENGLISH, #SUBLANG_ENGLISH_US)

Define hDll
Define DllFilename.s = "z:\test.dll"


CompilerIf #Method = 0
  
  Define hRsrc, *Copy, *Mem, StringLen, String.s, i, StringID, Max
  
  hDll = LoadLibraryEx_(DllFilename, 0, #LOAD_LIBRARY_AS_DATAFILE)
  If hDll
    
    For StringID = 10002 To 10029
      
      hRsrc = FindResourceEx_(hDll, #RT_STRING, StringID / 16 + 1, LangID)
      If hRsrc
        hGlobal = LoadResource_(hDll, hRsrc)
        If hGlobal
          *Mem = LockResource_(hGlobal)
          If *Mem
            *Copy = *Mem
            Max = StringID & 15
            For i = 0 To Max
              StringLen = PeekW(*Copy)
              *Copy + SizeOf(Word)
              String = PeekS(*Copy, StringLen)
              *Copy + StringLen * SizeOf(Character)
            Next
            
            Debug "ID: " + StringID + " , " + String
          EndIf
        EndIf
      EndIf
      
    Next
    
    FreeLibrary_(hDll)
  EndIf
  
CompilerElse
  
  ;The string indexes must be continuous.
  
  Procedure EnumResNameProc(hModule, *lpType, *lpName, *lParam)
    Protected String.s, hRsrc, hGlobal, *Copy, *Mem, i, id, StringLen
    
    hRsrc = FindResourceEx_(hModule, #RT_STRING, *lpName, *lParam)
    If hRsrc
      hGlobal = LoadResource_(hModule, hRsrc)
      If hGlobal
        *Mem = LockResource_(hGlobal)
        If *Mem
          *Copy = *Mem
          For i = 0 To 15
            StringLen = PeekW(*Copy)
            *Copy + SizeOf(Word)
            String = PeekS(*Copy, StringLen)
            *Copy + StringLen * SizeOf(Character)
            
            id = (*lpName - 1) * 16 + i
            
            If String
              Debug "ID: " + id + " , " + String
            EndIf
          Next
        EndIf
      EndIf
    EndIf
    
    ProcedureReturn #True
  EndProcedure
  
  hDll = LoadLibraryEx_(DllFilename, 0, #LOAD_LIBRARY_AS_DATAFILE)
  If hDll
    EnumResourceNames_(hDll, #RT_STRING, @EnumResNameProc(), LangID)
    
    FreeLibrary_(hDll)
  EndIf
  
CompilerEndIf
dempdeezzpp
User
User
Posts: 11
Joined: Wed Feb 03, 2021 12:04 am

Re: Software Localization from DLL

Post by dempdeezzpp »

you can work). very good decision!
Post Reply