Garry's Mod Wiki

string.Interpolate

  string string.Interpolate( string str, table lookuptable )

Just Added

This was just added in the latest version (2023.01.25). It might only be available on the Dev Branch right now.

Description

Interpolates a given string with the given table. This is useful for formatting localized strings.

Arguments

1 string str
The string that should be interpolated.
2 table lookuptable
The table to search in.

Returns

1 string
The modified string.

Example

Example on how to use this function.

local tbl = { ["Name"]= "Jerry" } print( string.Interpolate( "Hello {Name}!", tbl ) )
Output:
Hello Jerry!