In general one country cannot just print currency of other country. At least not legally, I suppose some countries could engage in counterfeiting.
A country has to go to foreign exchange market where they purchase the currency of the other country first and then make the transaction in that currency. In practice the foreign exchange market is ‘accessed’ just by making bank transfer where banks converts the money at the current exchange rate, same as you would when you order stuff from other country on internet or when on vacation.
Gold was used in international trade before modern age where gold and silver was kind of an universal currency. The only difference was in the gold and silver content of the coins so once that was accounted for, for all practical purposes, countries were basically in a monetary union - in fact Euro is often compared to gold standard see Eichengreen and Temin’s work on this here. But this system is no longer used as it’s impractical to ship gold between countries when floating exchange rates can do the same if not even better job with just paper fiat money.