Jump to content

Module talk:audio

Page contents not supported in other languages.
Add topic
From Wiktionary, the free dictionary
Latest comment: 5 months ago by Benwing2 in topic use of table

Usage

[edit]

@Surjection Hello, am I correctly understanding the usage of format_audios in this module? I am trying to call it like this:

local function show_audio_file(file, caption)
	caption = caption or "Audio"
	return require("Module:audio").format_audios (
		{
		  lang = lang,
		  audios = {{file = {file}, }, },
		  caption = caption
		}
	)
end

... to format audios in the module at Module:User:Kiril kovachev/bg-pronunciation. But I'm getting

Lua error: invalid replacement value (a table)

with a stack trace:

Backtrace:

  1. [C]: in function "v"
  2. mw.ustring.lua:84: in function "gsub"
  3. Module:audio:20: in function "format_audio_file"
  4. Module:audio:46: ?
  5. (tail call): ?
  6. Module:User:Kiril_kovachev/bg-pronunciation:401: in function "format_audio"
  7. Module:User:Kiril_kovachev/bg-pronunciation:447: in function "chunk"
  8. mw.lua:527: ?
  9. [C]: ?

As far as I can tell, I passed an object with the same format as the comment in the module described (I copy-pasted it an substituted my fields) but evidently I must be misunderstanding something. Thanks for any help, Kiril kovachev (talk) 12:41, 26 July 2023 (UTC)Reply

I think it is a typo in the documentation. The filename shouldn't be inside a one-element table, so the correct format is audios = {{file = file }, },SURJECTION / T / C / L / 20:11, 26 July 2023 (UTC)Reply
I see, thanks for the clarification. Kiril kovachev (talk) 10:46, 27 July 2023 (UTC)Reply

use of table

[edit]

@Ioaxxere Feel free to rework the HTML of the template. I just copied what was there already. Benwing2 (talk) 00:04, 4 June 2024 (UTC)Reply